|
|
@ -1275,9 +1275,11 @@ defmodule Explorer.Chain do |
|
|
|
Checks to see if the chain is down indexing based on the transaction from the |
|
|
|
Checks to see if the chain is down indexing based on the transaction from the |
|
|
|
oldest block and the pending operation |
|
|
|
oldest block and the pending operation |
|
|
|
""" |
|
|
|
""" |
|
|
|
@spec finished_internal_transactions_indexing?([api?]) :: boolean() |
|
|
|
@spec finished_indexing_internal_transactions?([api?]) :: boolean() |
|
|
|
def finished_internal_transactions_indexing?(options \\ []) do |
|
|
|
def finished_indexing_internal_transactions?(options \\ []) do |
|
|
|
internal_transactions_disabled? = System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true" |
|
|
|
internal_transactions_disabled? = |
|
|
|
|
|
|
|
Application.get_env(:indexer, Indexer.Fetcher.InternalTransaction.Supervisor)[:disabled?] or |
|
|
|
|
|
|
|
not Application.get_env(:indexer, Indexer.Supervisor)[:enabled] |
|
|
|
|
|
|
|
|
|
|
|
if internal_transactions_disabled? do |
|
|
|
if internal_transactions_disabled? do |
|
|
|
true |
|
|
|
true |
|
|
@ -1312,18 +1314,24 @@ defmodule Explorer.Chain do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def finished_blocks_indexing?(indexed_ratio_blocks) do |
|
|
|
def finished_indexing_from_ratio?(ratio) do |
|
|
|
Decimal.compare(indexed_ratio_blocks, 1) !== :lt |
|
|
|
Decimal.compare(ratio, 1) !== :lt |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
@doc """ |
|
|
|
Checks if indexing of blocks and internal transactions finished aka full indexing |
|
|
|
Checks if indexing of blocks and internal transactions finished aka full indexing |
|
|
|
""" |
|
|
|
""" |
|
|
|
@spec finished_indexing?(Decimal.t(), [api?]) :: boolean() |
|
|
|
@spec finished_indexing?([api?]) :: boolean() |
|
|
|
def finished_indexing?(indexed_ratio_blocks, options \\ []) do |
|
|
|
def finished_indexing?(options \\ []) do |
|
|
|
case finished_blocks_indexing?(indexed_ratio_blocks) do |
|
|
|
if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do |
|
|
|
|
|
|
|
indexed_ratio = indexed_ratio_blocks() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case finished_indexing_from_ratio?(indexed_ratio) do |
|
|
|
false -> false |
|
|
|
false -> false |
|
|
|
_ -> finished_internal_transactions_indexing?(options) |
|
|
|
_ -> finished_indexing_internal_transactions?(options) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
true |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -2181,6 +2189,7 @@ defmodule Explorer.Chain do |
|
|
|
""" |
|
|
|
""" |
|
|
|
@spec indexed_ratio_blocks() :: Decimal.t() |
|
|
|
@spec indexed_ratio_blocks() :: Decimal.t() |
|
|
|
def indexed_ratio_blocks do |
|
|
|
def indexed_ratio_blocks do |
|
|
|
|
|
|
|
if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do |
|
|
|
%{min: min, max: max} = BlockNumber.get_all() |
|
|
|
%{min: min, max: max} = BlockNumber.get_all() |
|
|
|
|
|
|
|
|
|
|
|
min_blockchain_block_number = |
|
|
|
min_blockchain_block_number = |
|
|
@ -2209,10 +2218,14 @@ defmodule Explorer.Chain do |
|
|
|
|> Decimal.round(2, :down) |
|
|
|
|> Decimal.round(2, :down) |
|
|
|
|> Decimal.min(Decimal.new(1)) |
|
|
|
|> Decimal.min(Decimal.new(1)) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Decimal.new(1) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@spec indexed_ratio_internal_transactions() :: Decimal.t() |
|
|
|
@spec indexed_ratio_internal_transactions() :: Decimal.t() |
|
|
|
def indexed_ratio_internal_transactions do |
|
|
|
def indexed_ratio_internal_transactions do |
|
|
|
|
|
|
|
if Application.get_env(:indexer, Indexer.Supervisor)[:enabled] do |
|
|
|
%{max: max} = BlockNumber.get_all() |
|
|
|
%{max: max} = BlockNumber.get_all() |
|
|
|
count = Repo.aggregate(PendingBlockOperation, :count, timeout: :infinity) |
|
|
|
count = Repo.aggregate(PendingBlockOperation, :count, timeout: :infinity) |
|
|
|
|
|
|
|
|
|
|
@ -2234,6 +2247,9 @@ defmodule Explorer.Chain do |
|
|
|
|> Decimal.round(2, :down) |
|
|
|
|> Decimal.round(2, :down) |
|
|
|
|> Decimal.min(Decimal.new(1)) |
|
|
|
|> Decimal.min(Decimal.new(1)) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Decimal.new(1) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@spec fetch_min_block_number() :: non_neg_integer |
|
|
|
@spec fetch_min_block_number() :: non_neg_integer |
|
|
|