node: Add cache buster for CoinGecko price queries (#3528)
This commit is contained in:
parent
49549eb01c
commit
630c5c3231
|
@ -12,8 +12,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -128,7 +130,13 @@ func (gov *ChainGovernor) PriceQuery(ctx context.Context) error {
|
||||||
// not been updated will be assigned their pre-configured price.
|
// not been updated will be assigned their pre-configured price.
|
||||||
func (gov *ChainGovernor) queryCoinGecko() error {
|
func (gov *ChainGovernor) queryCoinGecko() error {
|
||||||
result := make(map[string]interface{})
|
result := make(map[string]interface{})
|
||||||
|
|
||||||
|
// Cache buster of Unix timestamp concatenated with random number
|
||||||
|
params := url.Values{}
|
||||||
|
params.Add("bust", strconv.Itoa(int(time.Now().Unix()))+strconv.Itoa(rand.Int())) // #nosec G404
|
||||||
|
|
||||||
for queryIdx, query := range gov.coinGeckoQueries {
|
for queryIdx, query := range gov.coinGeckoQueries {
|
||||||
|
query := query + "&" + params.Encode()
|
||||||
thisResult, err := gov.queryCoinGeckoChunk(query)
|
thisResult, err := gov.queryCoinGeckoChunk(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gov.logger.Error("CoinGecko query failed", zap.Int("queryIdx", queryIdx), zap.String("query", query), zap.Error(err))
|
gov.logger.Error("CoinGecko query failed", zap.Int("queryIdx", queryIdx), zap.String("query", query), zap.Error(err))
|
||||||
|
|
Loading…
Reference in New Issue