Merge pull request #8594 from blockscout/fix-token-balance-fetcher

Fix TokenBalance fetcher retry logic
filter-token-transfers-from-coin-balance-address-updates
Victor Baranov 1 year ago committed by GitHub
commit f09dd0673f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      apps/indexer/lib/indexer/fetcher/token_balance.ex

@ -30,6 +30,7 @@
- [#7959](https://github.com/blockscout/blockscout/pull/7959) - Fix empty batch transfers handling - [#7959](https://github.com/blockscout/blockscout/pull/7959) - Fix empty batch transfers handling
- [#8513](https://github.com/blockscout/blockscout/pull/8513) - Don't override transaction status - [#8513](https://github.com/blockscout/blockscout/pull/8513) - Don't override transaction status
- [#8620](https://github.com/blockscout/blockscout/pull/8620) - Fix the display of icons - [#8620](https://github.com/blockscout/blockscout/pull/8620) - Fix the display of icons
- [#8594](https://github.com/blockscout/blockscout/pull/8594) - Fix TokenBalance fetcher retry logic
### Chore ### Chore

@ -117,17 +117,21 @@ defmodule Indexer.Fetcher.TokenBalance do
%{fetched_token_balances: fetched_token_balances, failed_token_balances: _failed_token_balances} = %{fetched_token_balances: fetched_token_balances, failed_token_balances: _failed_token_balances} =
1..@max_retries 1..@max_retries
|> Enum.reduce_while(%{fetched_token_balances: [], failed_token_balances: retryable_params_list}, fn _x, acc -> |> Enum.reduce_while(%{fetched_token_balances: [], failed_token_balances: retryable_params_list}, fn _x, acc ->
{:ok, {:ok, %{fetched_token_balances: fetched_token_balances, failed_token_balances: failed_token_balances}} =
%{fetched_token_balances: _fetched_token_balances, failed_token_balances: failed_token_balances} = TokenBalances.fetch_token_balances_from_blockchain(acc.failed_token_balances)
token_balances} = TokenBalances.fetch_token_balances_from_blockchain(acc.failed_token_balances)
all_token_balances = %{
fetched_token_balances: acc.fetched_token_balances ++ fetched_token_balances,
failed_token_balances: failed_token_balances
}
if Enum.empty?(failed_token_balances) do if Enum.empty?(failed_token_balances) do
{:halt, token_balances} {:halt, all_token_balances}
else else
failed_token_balances = increase_retries_count(failed_token_balances) failed_token_balances = increase_retries_count(failed_token_balances)
token_balances_updated_retries_count = token_balances_updated_retries_count =
token_balances all_token_balances
|> Map.put(:failed_token_balances, failed_token_balances) |> Map.put(:failed_token_balances, failed_token_balances)
{:cont, token_balances_updated_retries_count} {:cont, token_balances_updated_retries_count}

Loading…
Cancel
Save