As a result of #1657 out-of-place parent blocks are marked as non-consensus more reliably, i.e. they will eventually be fetched even if first attempt is unsuccessful. The `ConsensusEnsurer` module, on the contrary, only tried refetching block once, and left it as-is if the refetch failed. Now it is not needed anymore.pull/1684/head
parent
bc61808344
commit
9dbf51db94
@ -1,34 +0,0 @@ |
||||
defmodule Indexer.Block.Realtime.ConsensusEnsurer do |
||||
@moduledoc """ |
||||
Triggers a refetch if a given block doesn't have consensus. |
||||
|
||||
""" |
||||
require Logger |
||||
|
||||
alias Explorer.Chain |
||||
alias Explorer.Chain.Hash |
||||
alias Indexer.Block.Realtime.Fetcher |
||||
|
||||
def perform(_, number, _) when not is_integer(number) or number < 0, do: :ok |
||||
|
||||
def perform(%Hash{byte_count: unquote(Hash.Full.byte_count())} = block_hash, number, block_fetcher) do |
||||
case Chain.hash_to_block(block_hash) do |
||||
{:ok, %{consensus: true} = _block} -> |
||||
:ignore |
||||
|
||||
_ -> |
||||
Logger.info(fn -> |
||||
[ |
||||
"refetch from consensus was found on block (", |
||||
to_string(number), |
||||
"). A reorg initiated." |
||||
] |
||||
end) |
||||
|
||||
# trigger refetch if consensus=false or block was not found |
||||
Fetcher.fetch_and_import_block(number, block_fetcher, true) |
||||
end |
||||
|
||||
:ok |
||||
end |
||||
end |
Loading…
Reference in new issue