diff --git a/fiat/coingecko.go b/fiat/coingecko.go index 4ee5dd5d..b7e89708 100644 --- a/fiat/coingecko.go +++ b/fiat/coingecko.go @@ -59,7 +59,7 @@ type marketChartPrices struct { } // NewCoinGeckoDownloader creates a coingecko structure that implements the RatesDownloaderInterface -func NewCoinGeckoDownloader(db *db.RocksDB, url string, coin string, platformIdentifier string, platformVsCurrency string, allowedVsCurrencies string, timeFormat string, metrics *common.Metrics, throttleDown bool) RatesDownloaderInterface { +func NewCoinGeckoDownloader(db *db.RocksDB, coinShortcut string, url string, coin string, platformIdentifier string, platformVsCurrency string, allowedVsCurrencies string, timeFormat string, metrics *common.Metrics, throttleDown bool) RatesDownloaderInterface { throttlingDelayMs := 0 // No delay by default if throttleDown { throttlingDelayMs = DefaultThrottleDelayMs @@ -67,7 +67,10 @@ func NewCoinGeckoDownloader(db *db.RocksDB, url string, coin string, platformIde allowedVsCurrenciesMap := getAllowedVsCurrenciesMap(allowedVsCurrencies) - apiKey := os.Getenv("COINGECKO_API_KEY") + apiKey := os.Getenv(strings.ToUpper(coinShortcut) + "_COINGECKO_API_KEY") + if apiKey == "" { + apiKey = os.Getenv("COINGECKO_API_KEY") + } // use default address if not overridden, with respect to existence of apiKey if url == "" { diff --git a/fiat/fiat_rates.go b/fiat/fiat_rates.go index d0bdc37a..a9a37979 100644 --- a/fiat/fiat_rates.go +++ b/fiat/fiat_rates.go @@ -108,7 +108,7 @@ func NewFiatRates(db *db.RocksDB, config *common.Config, metrics *common.Metrics // a small hack - in tests the callback is not used, therefore there is no delay slowing down the test throttle = false } - fr.downloader = NewCoinGeckoDownloader(db, rdParams.URL, rdParams.Coin, rdParams.PlatformIdentifier, rdParams.PlatformVsCurrency, fr.allowedVsCurrencies, fr.timeFormat, metrics, throttle) + fr.downloader = NewCoinGeckoDownloader(db, db.GetInternalState().CoinShortcut, rdParams.URL, rdParams.Coin, rdParams.PlatformIdentifier, rdParams.PlatformVsCurrency, fr.allowedVsCurrencies, fr.timeFormat, metrics, throttle) if is != nil { is.HasFiatRates = true is.HasTokenFiatRates = fr.downloadTokens