Process review comment

pull/8613/head
Viktor Baranov 1 year ago
parent 2e0acd5471
commit d8da722a14
  1. 12
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
  2. 2
      apps/explorer/lib/explorer/chain.ex
  3. 16
      apps/explorer/lib/explorer/chain/import/runner/blocks.ex
  4. 2
      apps/indexer/lib/indexer/fetcher/internal_transaction.ex

@ -201,7 +201,7 @@ defmodule EthereumJSONRPC do
filtered_params_in_range =
filtered_params
|> Enum.filter(fn
%{block_quantity: block_quantity} -> block_number_in_range(block_quantity)
%{block_quantity: block_quantity} -> is_block_number_in_range?(block_quantity)
end)
id_to_params = id_to_params(filtered_params_in_range)
@ -240,7 +240,7 @@ defmodule EthereumJSONRPC do
@spec fetch_beneficiaries([block_number], json_rpc_named_arguments) ::
{:ok, FetchedBeneficiaries.t()} | {:error, reason :: term} | :ignore
def fetch_beneficiaries(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
filtered_block_numbers = block_numbers_in_range(block_numbers)
filtered_block_numbers = are_block_numbers_in_range?(block_numbers)
Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_beneficiaries(
filtered_block_numbers,
@ -345,7 +345,7 @@ defmodule EthereumJSONRPC do
Fetches internal transactions for entire blocks from variant API.
"""
def fetch_block_internal_transactions(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
filtered_block_numbers = block_numbers_in_range(block_numbers)
filtered_block_numbers = are_block_numbers_in_range?(block_numbers)
Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_block_internal_transactions(
filtered_block_numbers,
@ -353,7 +353,7 @@ defmodule EthereumJSONRPC do
)
end
def block_numbers_in_range(block_numbers) do
def are_block_numbers_in_range?(block_numbers) do
min_block = Application.get_env(:indexer, :trace_first_block)
max_block = Application.get_env(:indexer, :trace_last_block)
@ -455,8 +455,8 @@ defmodule EthereumJSONRPC do
end
end
@spec block_number_in_range(quantity) :: boolean()
defp block_number_in_range(block_quantity) do
@spec is_block_number_in_range?(quantity) :: boolean()
defp is_block_number_in_range?(block_quantity) do
min_block = Application.get_env(:indexer, :trace_first_block)
max_block = Application.get_env(:indexer, :trace_last_block)
block_number = quantity_to_integer(block_quantity)

@ -5828,7 +5828,7 @@ defmodule Explorer.Chain do
if transaction_index == 0 do
0
else
filtered_block_numbers = EthereumJSONRPC.block_numbers_in_range([block_number])
filtered_block_numbers = EthereumJSONRPC.are_block_numbers_in_range?([block_number])
{:ok, traces} = fetch_block_internal_transactions(filtered_block_numbers, json_rpc_named_arguments)
sorted_traces =

@ -60,15 +60,9 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
hashes = Enum.map(changes_list, & &1.hash)
minimal_block_height = Application.get_env(:indexer, :trace_first_block)
maximal_block_height = Application.get_env(:indexer, :trace_last_block)
items_for_pending_ops =
changes_list
|> filter_by_height_range(
&(&1.number >= minimal_block_height &&
if(maximal_block_height, do: &1.number <= maximal_block_height, else: true))
)
|> filter_by_height_range(&is_block_in_range?(&1.number))
|> Enum.filter(& &1.consensus)
|> Enum.map(&{&1.number, &1.hash})
@ -78,7 +72,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
run_func = fn repo ->
{:ok, nonconsensus_items} = lose_consensus(repo, hashes, consensus_block_numbers, changes_list, insert_options)
{:ok, filter_by_height_range(nonconsensus_items, fn {number, _hash} -> number >= minimal_block_height end)}
{:ok, filter_by_height_range(nonconsensus_items, fn {number, _hash} -> is_block_in_range?(number) end)}
end
multi
@ -220,6 +214,12 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
@impl Runner
def timeout, do: @timeout
defp is_block_in_range?(number) do
minimal_block_height = Application.get_env(:indexer, :trace_first_block)
maximal_block_height = Application.get_env(:indexer, :trace_last_block)
number >= minimal_block_height && if(maximal_block_height, do: number <= maximal_block_height, else: true)
end
defp fork_transactions(%{
repo: repo,
timeout: timeout,

@ -100,7 +100,7 @@ defmodule Indexer.Fetcher.InternalTransaction do
filtered_unique_numbers =
unique_numbers
|> EthereumJSONRPC.block_numbers_in_range()
|> EthereumJSONRPC.are_block_numbers_in_range?()
|> drop_genesis(json_rpc_named_arguments)
filtered_unique_numbers_count = Enum.count(filtered_unique_numbers)

Loading…
Cancel
Save