|
|
|
@ -290,8 +290,14 @@ defmodule Indexer.Block.Realtime.Fetcher do |
|
|
|
|
|
|
|
|
|
@decorate span(tracer: Tracer) |
|
|
|
|
defp do_fetch_and_import_block(block_number_to_fetch, block_fetcher, retry) do |
|
|
|
|
case fetch_and_import_range(block_fetcher, block_number_to_fetch..block_number_to_fetch) do |
|
|
|
|
{:ok, %{inserted: _, errors: []}} -> |
|
|
|
|
time_before = Timex.now() |
|
|
|
|
|
|
|
|
|
{fetch_duration, result} = |
|
|
|
|
:timer.tc(fn -> fetch_and_import_range(block_fetcher, block_number_to_fetch..block_number_to_fetch) end) |
|
|
|
|
|
|
|
|
|
case result do |
|
|
|
|
{:ok, %{inserted: inserted, errors: []}} -> |
|
|
|
|
log_import_timings(inserted, fetch_duration, time_before) |
|
|
|
|
Logger.debug("Fetched and imported.") |
|
|
|
|
|
|
|
|
|
{:ok, %{inserted: _, errors: [_ | _] = errors}} -> |
|
|
|
@ -355,6 +361,14 @@ defmodule Indexer.Block.Realtime.Fetcher do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp log_import_timings(%{blocks: [%{number: number, timestamp: timestamp}]}, fetch_duration, time_before) do |
|
|
|
|
node_delay = Timex.diff(time_before, timestamp, :seconds) |
|
|
|
|
|
|
|
|
|
Logger.info("Block #{number} fetching duration: #{fetch_duration / 1_000_000}s. Node delay: #{node_delay}s.") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp log_import_timings(_inserted, _duration, _time_before), do: nil |
|
|
|
|
|
|
|
|
|
defp retry_fetch_and_import_block(%{retry: retry}) when retry < 1, do: :ignore |
|
|
|
|
|
|
|
|
|
defp retry_fetch_and_import_block(%{changesets: changesets} = params) do |
|
|
|
|