@ -159,8 +159,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
@decorate trace ( name : " fetch " , resource : " Indexer.Block.Realtime.Fetcher.fetch_and_import_block/3 " , tracer : Tracer )
@decorate trace ( name : " fetch " , resource : " Indexer.Block.Realtime.Fetcher.fetch_and_import_block/3 " , tracer : Tracer )
def fetch_and_import_block ( block_number_to_fetch , block_fetcher , reorg? , retry \\ 3 ) do
def fetch_and_import_block ( block_number_to_fetch , block_fetcher , reorg? , retry \\ 3 ) do
Logger . metadata ( fetcher : :block_realtime )
Indexer.Logger . metadata ( fn ->
if reorg? do
if reorg? do
# give previous fetch attempt (for same block number) a chance to finish
# give previous fetch attempt (for same block number) a chance to finish
# before fetching again, to reduce block consensus mistakes
# before fetching again, to reduce block consensus mistakes
@ -168,6 +167,7 @@ defmodule Indexer.Block.Realtime.Fetcher do
end
end
do_fetch_and_import_block ( block_number_to_fetch , block_fetcher , retry )
do_fetch_and_import_block ( block_number_to_fetch , block_fetcher , retry )
end , fetcher : :block_realtime , block_number : block_number_to_fetch )
end
end
@decorate span ( tracer : Tracer )
@decorate span ( tracer : Tracer )
@ -179,16 +179,12 @@ defmodule Indexer.Block.Realtime.Fetcher do
Task.Supervisor . start_child ( TaskSupervisor , ConsensusEnsurer , :perform , args )
Task.Supervisor . start_child ( TaskSupervisor , ConsensusEnsurer , :perform , args )
end
end
Logger . debug ( fn ->
Logger . debug ( " Fetched and imported. " )
[ " fetched and imported block " , to_string ( block_number_to_fetch ) ]
end )
{ :ok , %{ inserted : _ , errors : [ _ | _ ] = errors } } ->
{ :ok , %{ inserted : _ , errors : [ _ | _ ] = errors } } ->
Logger . error ( fn ->
Logger . error ( fn ->
[
[
" failed to fetch block " ,
" failed to fetch block: " ,
to_string ( block_number_to_fetch ) ,
" : " ,
inspect ( errors ) ,
inspect ( errors ) ,
" . Block will be retried by catchup indexer. "
" . Block will be retried by catchup indexer. "
]
]
@ -199,8 +195,6 @@ defmodule Indexer.Block.Realtime.Fetcher do
[
[
" failed to fetch " ,
" failed to fetch " ,
to_string ( step ) ,
to_string ( step ) ,
" for block " ,
to_string ( block_number_to_fetch ) ,
" : " ,
" : " ,
inspect ( reason ) ,
inspect ( reason ) ,
" . Block will be retried by catchup indexer. "
" . Block will be retried by catchup indexer. "
@ -232,8 +226,6 @@ defmodule Indexer.Block.Realtime.Fetcher do
[
[
" failed to insert " ,
" failed to insert " ,
to_string ( step ) ,
to_string ( step ) ,
" for block " ,
to_string ( block_number_to_fetch ) ,
" : " ,
" : " ,
inspect ( failed_value ) ,
inspect ( failed_value ) ,
" . Block will be retried by catchup indexer. "
" . Block will be retried by catchup indexer. "