|
|
|
@ -15,7 +15,7 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
|
|
|
|
|
alias Explorer.{Chain, Repo} |
|
|
|
|
alias Explorer.Helper, as: ExplorerHelper |
|
|
|
|
alias Explorer.Chain.{Log, TransactionAction} |
|
|
|
|
alias Explorer.Chain.{Block, Log, TransactionAction} |
|
|
|
|
alias Indexer.Transform.{Addresses, TransactionActions} |
|
|
|
|
|
|
|
|
|
@stage_first_block "tx_action_first_block" |
|
|
|
@ -87,8 +87,10 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
if reason === :normal do |
|
|
|
|
{:noreply, %__MODULE__{state | task: nil}} |
|
|
|
|
else |
|
|
|
|
logger_metadata = Logger.metadata() |
|
|
|
|
Logger.metadata(fetcher: :transaction_action) |
|
|
|
|
Logger.error(fn -> "Transaction action fetcher task exited due to #{inspect(reason)}. Rerunning..." end) |
|
|
|
|
Logger.reset_metadata(logger_metadata) |
|
|
|
|
{:noreply, run_fetch(%__MODULE__{state | next_block: get_stage_block(@stage_next_block)})} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -108,6 +110,7 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
pid: pid |
|
|
|
|
} = _state |
|
|
|
|
) do |
|
|
|
|
logger_metadata = Logger.metadata() |
|
|
|
|
Logger.metadata(fetcher: :transaction_action) |
|
|
|
|
|
|
|
|
|
block_range = Range.new(next_block, first_block, -1) |
|
|
|
@ -117,6 +120,8 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
query = |
|
|
|
|
from( |
|
|
|
|
log in Log, |
|
|
|
|
inner_join: b in Block, |
|
|
|
|
on: b.hash == log.block_hash and b.consensus == true, |
|
|
|
|
where: log.block_number == ^block_number, |
|
|
|
|
select: log |
|
|
|
|
) |
|
|
|
@ -183,15 +188,19 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
|
|
|
|
|
Process.send(pid, :stop_server, []) |
|
|
|
|
|
|
|
|
|
Logger.reset_metadata(logger_metadata) |
|
|
|
|
|
|
|
|
|
:ok |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp init_fetching(opts, first_block, last_block) do |
|
|
|
|
logger_metadata = Logger.metadata() |
|
|
|
|
Logger.metadata(fetcher: :transaction_action) |
|
|
|
|
|
|
|
|
|
first_block = ExplorerHelper.parse_integer(first_block) |
|
|
|
|
last_block = ExplorerHelper.parse_integer(last_block) |
|
|
|
|
|
|
|
|
|
return = |
|
|
|
|
if is_nil(first_block) or is_nil(last_block) or first_block <= 0 or last_block <= 0 or first_block > last_block do |
|
|
|
|
{:stop, "Correct block range must be provided to #{__MODULE__}."} |
|
|
|
|
else |
|
|
|
@ -228,6 +237,10 @@ defmodule Indexer.Fetcher.TransactionAction do |
|
|
|
|
|
|
|
|
|
{:ok, state} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Logger.reset_metadata(logger_metadata) |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp get_next_block(first_block, last_block, protocols) do |
|
|
|
|