فهرست منبع

node/governor: handle type assertion error

tbjump 2 سال پیش
والد
کامیت
a5092db982
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      node/pkg/governor/governor_prices.go

+ 6 - 2
node/pkg/governor/governor_prices.go

@@ -156,8 +156,12 @@ func (gov *ChainGovernor) queryCoinGecko() error {
 		if exists {
 		if exists {
 			// If a price is not set in CoinGecko, they return an empty entry. Treat that as a zero price.
 			// If a price is not set in CoinGecko, they return an empty entry. Treat that as a zero price.
 			var price float64
 			var price float64
-
-			m := data.(map[string]interface{})
+			m, ok := data.(map[string]interface{})
+			if !ok {
+				gov.logger.Error("failed to parse CoinGecko response, reverting to configured price for this token", zap.String("coinGeckoId", coinGeckoId))
+				// By continuing, we leave this one in the local map so the price will get reverted below.
+				continue
+			}
 			if len(m) != 0 {
 			if len(m) != 0 {
 				var ok bool
 				var ok bool
 				price_, ok := m["usd"]
 				price_, ok := m["usd"]