Skip to content

Commit

Permalink
fix: make circ supply update every 5 min
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Jun 27, 2024
1 parent 9b526ee commit 8ce81c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/api/rest/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func handlerGetAddressDetails(c *fiber.Ctx) error {
return c.SendString(`{"error": "address required"}`)
}

params := new(AddressesQuery)
params := new(SkipLimitQuery)
if err := c.QueryParser(params); err != nil {
zap.S().Warnf("Addresses Get Handler ERROR: %s", err.Error())
c.Status(422)
Expand Down Expand Up @@ -338,6 +338,13 @@ func handlerGetContracts(c *fiber.Ctx) error {
func handlerGetTokenAddresses(c *fiber.Ctx) error {
addressString := c.Params("address")

params := new(SkipLimitQuery)
if err := c.QueryParser(params); err != nil {
zap.S().Warnf("Addresses Get Handler ERROR: %s", err.Error())
c.Status(422)
return c.SendString(`{"error": "could not parse query parameters"}`)
}

// Get TokenAddresses
tokenAddress, err := crud.GetTokenAddressCrud().SelectManyByAddress(addressString)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions src/api/rest/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func handlerGetTransactionAddress(c *fiber.Ctx) error {
return c.SendString(`{"error": "address required"}`)
}

params := new(TransactionsQuery)
params := new(SkipLimitQuery)
if err := c.QueryParser(params); err != nil {
c.Status(422)
return c.SendString(`{"error": "could not parse query parameters"}`)
Expand Down Expand Up @@ -813,7 +813,7 @@ func handlerGetTokenTransfersAddress(c *fiber.Ctx) error {
return c.SendString(`{"error": "address required"}`)
}

params := new(TransactionsQuery)
params := new(SkipLimitQuery)
if err := c.QueryParser(params); err != nil {
zap.S().Warnf("Transactions Get Handler ERROR: %s", err.Error())

Expand Down
5 changes: 5 additions & 0 deletions src/api/rest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"strconv"
)

type SkipLimitQuery struct {
Limit int `query:"limit"`
Skip int `query:"skip"`
}

// https://stackoverflow.com/a/28818489/12642712
func newTrue() *bool {
b := true
Expand Down
4 changes: 2 additions & 2 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ type configType struct {
IconNodeRpcRetryAttempts int `envconfig:"ICON_NODE_RPC_RETRY_ATTEMPTS" required:"false" default:"20"`

// Stats endpoints
StatsMarketCapUpdateTime time.Duration `envconfig:"STATS_MARKET_CAP_UPDATE_TIME" required:"false" default:"1h"`
StatsCirculatingSupplyUpdateTime time.Duration `envconfig:"STATS_CIRCULATING_SUPPLY_UPDATE_TIME" required:"false" default:"1h"`
StatsMarketCapUpdateTime time.Duration `envconfig:"STATS_MARKET_CAP_UPDATE_TIME" required:"false" default:"5m"`
StatsCirculatingSupplyUpdateTime time.Duration `envconfig:"STATS_CIRCULATING_SUPPLY_UPDATE_TIME" required:"false" default:"5m"`
}

// Config - runtime config struct
Expand Down

0 comments on commit 8ce81c9

Please sign in to comment.