From ad7e15ca3bd4748e541e215a610adac2cda99db8 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Wed, 22 Aug 2018 16:00:43 -0500 Subject: [PATCH] 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`. --- .../lib/indexer/block_fetcher/realtime.ex | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/indexer/lib/indexer/block_fetcher/realtime.ex b/apps/indexer/lib/indexer/block_fetcher/realtime.ex index 6d2ec7cccd..d641af09d1 100644 --- a/apps/indexer/lib/indexer/block_fetcher/realtime.ex +++ b/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