fix_: fallback to cache for token prices when calling GetWalletToken

This commit is contained in:
Sean Hagstrom 2024-09-13 12:20:33 +01:00
parent 5cc39ac272
commit b4fe4c9085
No known key found for this signature in database
GPG Key ID: 5257FEDF56307320
1 changed files with 4 additions and 4 deletions

View File

@ -479,15 +479,15 @@ func (r *Reader) GetWalletToken(ctx context.Context, clients map[uint64]chain.Cl
var (
group = async.NewAtomicGroup(ctx)
prices = map[string]map[string]float64{}
prices = map[string]map[string]market.DataPoint{}
tokenDetails = map[string]thirdparty.TokenDetails{}
tokenMarketValues = map[string]thirdparty.TokenMarketValues{}
)
group.Add(func(parent context.Context) error {
prices, err = r.marketManager.FetchPrices(tokenSymbols, currencies)
prices, err = r.marketManager.GetOrFetchPrices(tokenSymbols, currencies, 60)
if err != nil {
log.Info("marketManager.FetchPrices err", err)
log.Info("marketManager.GetOrFetchPrices err", err)
}
return nil
})
@ -533,7 +533,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, clients map[uint64]chain.Cl
ChangePctDay: tokenMarketValues[tok.Symbol].CHANGEPCTDAY,
ChangePct24hour: tokenMarketValues[tok.Symbol].CHANGEPCT24HOUR,
Change24hour: tokenMarketValues[tok.Symbol].CHANGE24HOUR,
Price: prices[tok.Symbol][currency],
Price: prices[tok.Symbol][currency].Price,
HasError: !r.marketManager.IsConnected,
}
}