@ -97,22 +97,26 @@ defmodule Indexer.Block.Realtime.Fetcher do
transactions : %{ params : transactions_params }
transactions : %{ params : transactions_params }
} = options
} = options
) do
) do
with { :ok ,
with { :internal_transactions ,
%{
{ :ok ,
addresses_params : internal_transactions_addresses_params ,
%{
internal_transactions_params : internal_transactions_params
} } <-
internal_transactions ( block_fetcher , %{
addresses_params : addresses_params ,
transactions_params : transactions_params
} ) ,
{ :ok , %{ addresses_params : balances_addresses_params , balances_params : balances_params } } <-
balances ( block_fetcher , %{
address_hash_to_block_number : address_hash_to_block_number ,
addresses_params : internal_transactions_addresses_params ,
addresses_params : internal_transactions_addresses_params ,
balances_params : address_coin_balances_params
internal_transactions_params : internal_transactions_params
} ) ,
} } } <-
{ :ok , address_token_balances } <- fetch_token_balances ( address_token_balances_params ) ,
{ :internal_transactions ,
internal_transactions ( block_fetcher , %{
addresses_params : addresses_params ,
transactions_params : transactions_params
} ) } ,
{ :balances , { :ok , %{ addresses_params : balances_addresses_params , balances_params : balances_params } } } <-
{ :balances ,
balances ( block_fetcher , %{
address_hash_to_block_number : address_hash_to_block_number ,
addresses_params : internal_transactions_addresses_params ,
balances_params : address_coin_balances_params
} ) } ,
{ :address_token_balances , { :ok , address_token_balances } } <-
{ :address_token_balances , fetch_token_balances ( address_token_balances_params ) } ,
chain_import_options =
chain_import_options =
options
options
|> Map . drop ( @import_options )
|> Map . drop ( @import_options )
@ -122,7 +126,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
|> put_in ( [ Access . key ( :address_current_token_balances , %{ } ) , :params ] , address_token_balances )
|> put_in ( [ Access . key ( :address_current_token_balances , %{ } ) , :params ] , address_token_balances )
|> put_in ( [ Access . key ( :address_token_balances ) , :params ] , address_token_balances )
|> put_in ( [ Access . key ( :address_token_balances ) , :params ] , address_token_balances )
|> put_in ( [ Access . key ( :internal_transactions , %{ } ) , :params ] , internal_transactions_params ) ,
|> put_in ( [ Access . key ( :internal_transactions , %{ } ) , :params ] , internal_transactions_params ) ,
{ :ok , imported } = ok <- Chain . import ( chain_import_options ) do
{ :import , { : ok , imported } = ok } <- { :import , Chain . import ( chain_import_options ) } do
async_import_remaining_block_data ( imported )
async_import_remaining_block_data ( imported )
ok
ok
end
end
@ -194,19 +198,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
]
]
end )
end )
{ :error , { step , reason } } ->
{ :error , { :import , [ % Changeset { } | _ ] = changesets } } ->
Logger . error (
fn ->
[
" failed to fetch: " ,
inspect ( reason ) ,
" . Block will be retried by catchup indexer. "
]
end ,
step : step
)
{ :error , [ % Changeset { } | _ ] = changesets } ->
params = %{
params = %{
changesets : changesets ,
changesets : changesets ,
block_number_to_fetch : block_number_to_fetch ,
block_number_to_fetch : block_number_to_fetch ,
@ -226,6 +218,18 @@ defmodule Indexer.Block.Realtime.Fetcher do
end )
end )
end
end
{ :error , { step , reason } } ->
Logger . error (
fn ->
[
" failed to fetch: " ,
inspect ( reason ) ,
" . Block will be retried by catchup indexer. "
]
end ,
step : step
)
{ :error , { step , failed_value , _changes_so_far } } ->
{ :error , { step , failed_value , _changes_so_far } } ->
Logger . error (
Logger . error (
fn ->
fn ->