|
|
@ -846,20 +846,27 @@ defmodule Explorer.Chain do |
|
|
|
""" |
|
|
|
""" |
|
|
|
@spec finished_indexing?() :: boolean() |
|
|
|
@spec finished_indexing?() :: boolean() |
|
|
|
def finished_indexing? do |
|
|
|
def finished_indexing? do |
|
|
|
with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, |
|
|
|
json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments) |
|
|
|
min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do |
|
|
|
variant = Keyword.fetch!(json_rpc_named_arguments, :variant) |
|
|
|
query = |
|
|
|
|
|
|
|
from( |
|
|
|
|
|
|
|
b in Block, |
|
|
|
|
|
|
|
join: pending_ops in assoc(b, :pending_operations), |
|
|
|
|
|
|
|
where: pending_ops.fetch_internal_transactions, |
|
|
|
|
|
|
|
where: b.consensus and b.number == ^min_block_number |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!Repo.exists?(query) |
|
|
|
if variant == EthereumJSONRPC.Ganache do |
|
|
|
|
|
|
|
true |
|
|
|
else |
|
|
|
else |
|
|
|
{:transactions_exist, false} -> true |
|
|
|
with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, |
|
|
|
nil -> false |
|
|
|
min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do |
|
|
|
|
|
|
|
query = |
|
|
|
|
|
|
|
from( |
|
|
|
|
|
|
|
b in Block, |
|
|
|
|
|
|
|
join: pending_ops in assoc(b, :pending_operations), |
|
|
|
|
|
|
|
where: pending_ops.fetch_internal_transactions, |
|
|
|
|
|
|
|
where: b.consensus and b.number == ^min_block_number |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!Repo.exists?(query) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{:transactions_exist, false} -> true |
|
|
|
|
|
|
|
nil -> false |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|