|
|
@ -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} |
|
|
|