Skip to content

Commit

Permalink
fix: Fix address coin balances transformer (blockscout#11627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwerty5Uiop authored Jan 22, 2025
1 parent d0c04c0 commit cca0b44
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/indexer/lib/indexer/transform/address_coin_balances.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ defmodule Indexer.Transform.AddressCoinBalances do
end

defp reducer({:blocks_params, blocks_params}, acc) when is_list(blocks_params) do
# a block MUST have a miner_hash and number
Enum.into(blocks_params, acc, fn %{miner_hash: address_hash, number: block_number}
when is_binary(address_hash) and is_integer(block_number) ->
%{address_hash: address_hash, block_number: block_number}
end)
Enum.reduce(blocks_params, acc, &blocks_params_reducer/2)
end

defp reducer({:internal_transactions_params, internal_transactions_params}, initial)
Expand Down Expand Up @@ -65,6 +61,13 @@ defmodule Indexer.Transform.AddressCoinBalances do
end)
end

defp blocks_params_reducer(%{miner_hash: address_hash, number: block_number}, acc)
when is_binary(address_hash) and is_integer(block_number) do
MapSet.put(acc, %{address_hash: address_hash, block_number: block_number})
end

defp blocks_params_reducer(_block_params, acc), do: acc

defp internal_transactions_params_reducer(%{block_number: block_number} = internal_transaction_params, acc)
when is_integer(block_number) do
case internal_transaction_params do
Expand Down

0 comments on commit cca0b44

Please sign in to comment.