Fetch balances when db cache doesn't exist (second attempt) (#4714)

This commit is contained in:
Roman Volosovskyi 2024-02-12 13:29:31 +01:00 committed by GitHub
parent 8d4f4904c6
commit af16669787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -275,8 +275,17 @@ func (r *Reader) FetchOrGetCachedWalletBalances(ctx context.Context, addresses [
} }
tokens, err := r.persistence.GetTokens() tokens, err := r.persistence.GetTokens()
addressWithoutCachedBalances := false
for _, address := range addresses {
if _, ok := tokens[address]; !ok {
addressWithoutCachedBalances = true
break
}
}
// there should be at least ETH balance // there should be at least ETH balance
if len(tokens) == 0 { if addressWithoutCachedBalances {
return r.GetWalletTokenBalances(ctx, addresses) return r.GetWalletTokenBalances(ctx, addresses)
} }