|
|
@ -1199,6 +1199,17 @@ defmodule Explorer.Chain do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
|
|
|
|
Checks if indexing of blocks and internal transactions finished aka full indexing |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
@spec finished_indexing?(Decimal.t()) :: boolean() |
|
|
|
|
|
|
|
def finished_indexing?(indexed_ratio) do |
|
|
|
|
|
|
|
case Decimal.compare(indexed_ratio, 1) do |
|
|
|
|
|
|
|
:lt -> false |
|
|
|
|
|
|
|
_ -> Chain.finished_internal_transactions_indexing?() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
@doc """ |
|
|
|
The `t:Explorer.Chain.Transaction.t/0` `gas_price` of the `transaction` in `unit`. |
|
|
|
The `t:Explorer.Chain.Transaction.t/0` `gas_price` of the `transaction` in `unit`. |
|
|
|
""" |
|
|
|
""" |
|
|
@ -2064,14 +2075,22 @@ defmodule Explorer.Chain do |
|
|
|
def indexed_ratio do |
|
|
|
def indexed_ratio do |
|
|
|
%{min: min, max: max} = BlockNumber.get_all() |
|
|
|
%{min: min, max: max} = BlockNumber.get_all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
min_blockchain_block_number = |
|
|
|
|
|
|
|
case Integer.parse(Application.get_env(:indexer, :first_block)) do |
|
|
|
|
|
|
|
{block_number, _} -> block_number |
|
|
|
|
|
|
|
_ -> 0 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
case {min, max} do |
|
|
|
case {min, max} do |
|
|
|
{0, 0} -> |
|
|
|
{0, 0} -> |
|
|
|
Decimal.new(0) |
|
|
|
Decimal.new(0) |
|
|
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
_ -> |
|
|
|
result = Decimal.div(max - min + 1, max + 1) |
|
|
|
result = Decimal.div(max - min + 1, max - min_blockchain_block_number + 1) |
|
|
|
|
|
|
|
|
|
|
|
Decimal.round(result, 2, :down) |
|
|
|
result |
|
|
|
|
|
|
|
|> Decimal.round(2, :down) |
|
|
|
|
|
|
|
|> Decimal.min(Decimal.new(1)) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|