Handle :ignore from EthereumJSONRPC.fetch_internal_transactions

`c:EthereumJSONRPC.fetch_internal_transactions/2` can return `:ignore`
as it does for `EthereumJSONRPC.Geth` because it doesn't currently
support internal transactions, but
`Indexer.BlockFetcher.Realtime.internal_transactions/2` did not handle
`:ignore` and forwarded it along instead.  Switch the `with` to a `case`
so we don't forward unexpected returns in the future.  Make `:ignore`
return empty `:internal_transaction_params`.
pull/547/head
Luke Imhoff 6 years ago
parent 355fbcf9c7
commit ad7e15ca3b
  1. 28
      apps/indexer/lib/indexer/block_fetcher/realtime.ex

@ -147,17 +147,23 @@ defmodule Indexer.BlockFetcher.Realtime do
%BlockFetcher{json_rpc_named_arguments: json_rpc_named_arguments},
%{addresses_params: addresses_params, transactions_params: transactions_params}
) do
with {:ok, internal_transactions_params} <-
transactions_params
|> transactions_params_to_fetch_internal_transactions_params()
|> EthereumJSONRPC.fetch_internal_transactions(json_rpc_named_arguments) do
merged_addresses_params =
%{internal_transactions: internal_transactions_params}
|> AddressExtraction.extract_addresses()
|> Kernel.++(addresses_params)
|> AddressExtraction.merge_addresses()
{:ok, %{addresses_params: merged_addresses_params, internal_transactions_params: internal_transactions_params}}
case transactions_params
|> transactions_params_to_fetch_internal_transactions_params()
|> EthereumJSONRPC.fetch_internal_transactions(json_rpc_named_arguments) do
{:ok, internal_transactions_params} ->
merged_addresses_params =
%{internal_transactions: internal_transactions_params}
|> AddressExtraction.extract_addresses()
|> Kernel.++(addresses_params)
|> AddressExtraction.merge_addresses()
{:ok, %{addresses_params: merged_addresses_params, internal_transactions_params: internal_transactions_params}}
:ignore ->
{:ok, %{addresses_params: addresses_params, internal_transactions_params: []}}
{:error, _reason} = error ->
error
end
end

Loading…
Cancel
Save