|
|
|
@ -285,11 +285,13 @@ defmodule Indexer.AddressExtraction do |
|
|
|
|
...> transactions: [ |
|
|
|
|
...> %{ |
|
|
|
|
...> block_number: 3, |
|
|
|
|
...> to_address_hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
...> to_address_hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
...> nonce: 5 |
|
|
|
|
...> }, |
|
|
|
|
...> %{ |
|
|
|
|
...> block_number: 2, |
|
|
|
|
...> from_address_hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
...> from_address_hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
...> nonce: 4 |
|
|
|
|
...> } |
|
|
|
|
...> ], |
|
|
|
|
...> logs: [ |
|
|
|
@ -303,7 +305,8 @@ defmodule Indexer.AddressExtraction do |
|
|
|
|
[ |
|
|
|
|
%{ |
|
|
|
|
fetched_coin_balance_block_number: 7, |
|
|
|
|
hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
nonce: 4 |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -322,11 +325,13 @@ defmodule Indexer.AddressExtraction do |
|
|
|
|
...> transactions: [ |
|
|
|
|
...> %{ |
|
|
|
|
...> block_number: 2, |
|
|
|
|
...> from_address_hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
...> from_address_hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
...> nonce: 4 |
|
|
|
|
...> }, |
|
|
|
|
...> %{ |
|
|
|
|
...> block_number: 3, |
|
|
|
|
...> to_address_hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
...> to_address_hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
...> nonce: 5 |
|
|
|
|
...> } |
|
|
|
|
...> ] |
|
|
|
|
...> } |
|
|
|
@ -335,7 +340,8 @@ defmodule Indexer.AddressExtraction do |
|
|
|
|
%{ |
|
|
|
|
contract_code: "0x", |
|
|
|
|
fetched_coin_balance_block_number: 3, |
|
|
|
|
hash: "0x0000000000000000000000000000000000000001" |
|
|
|
|
hash: "0x0000000000000000000000000000000000000001", |
|
|
|
|
nonce: 4 |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -452,38 +458,41 @@ defmodule Indexer.AddressExtraction do |
|
|
|
|
|
|
|
|
|
# Ensure that when `:addresses` or `:address_coin_balances` are present, their :fetched_coin_balance will win |
|
|
|
|
defp merge_addresses(%{hash: hash} = first, %{hash: hash} = second) do |
|
|
|
|
case {first[:fetched_coin_balance], second[:fetched_coin_balance]} do |
|
|
|
|
{nil, nil} -> |
|
|
|
|
first |
|
|
|
|
|> Map.merge(second) |
|
|
|
|
|> Map.put( |
|
|
|
|
:fetched_coin_balance_block_number, |
|
|
|
|
max_nil_last( |
|
|
|
|
Map.get(first, :fetched_coin_balance_block_number), |
|
|
|
|
Map.get(second, :fetched_coin_balance_block_number) |
|
|
|
|
merged_addresses = |
|
|
|
|
case {first[:fetched_coin_balance], second[:fetched_coin_balance]} do |
|
|
|
|
{nil, nil} -> |
|
|
|
|
first |
|
|
|
|
|> Map.merge(second) |
|
|
|
|
|> Map.put( |
|
|
|
|
:fetched_coin_balance_block_number, |
|
|
|
|
max_nil_last( |
|
|
|
|
Map.get(first, :fetched_coin_balance_block_number), |
|
|
|
|
Map.get(second, :fetched_coin_balance_block_number) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
{nil, _} -> |
|
|
|
|
# merge in `second` so its balance and block_number wins |
|
|
|
|
Map.merge(first, second) |
|
|
|
|
|
|
|
|
|
{_, nil} -> |
|
|
|
|
# merge in `first` so its balance and block_number wins |
|
|
|
|
Map.merge(second, first) |
|
|
|
|
|
|
|
|
|
{_, _} -> |
|
|
|
|
if greater_than_nil_last( |
|
|
|
|
Map.get(first, :fetched_coin_balance_block_number), |
|
|
|
|
Map.get(second, :fetched_coin_balance_block_number) |
|
|
|
|
) do |
|
|
|
|
# merge in `first` so its block number wins |
|
|
|
|
Map.merge(second, first) |
|
|
|
|
else |
|
|
|
|
# merge in `second` so its block number wins |
|
|
|
|
|
|
|
|
|
{nil, _} -> |
|
|
|
|
# merge in `second` so its balance and block_number wins |
|
|
|
|
Map.merge(first, second) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
{_, nil} -> |
|
|
|
|
# merge in `first` so its balance and block_number wins |
|
|
|
|
Map.merge(second, first) |
|
|
|
|
|
|
|
|
|
{_, _} -> |
|
|
|
|
if greater_than_nil_last( |
|
|
|
|
Map.get(first, :fetched_coin_balance_block_number), |
|
|
|
|
Map.get(second, :fetched_coin_balance_block_number) |
|
|
|
|
) do |
|
|
|
|
# merge in `first` so its block number wins |
|
|
|
|
Map.merge(second, first) |
|
|
|
|
else |
|
|
|
|
# merge in `second` so its block number wins |
|
|
|
|
Map.merge(first, second) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
merged_addresses |
|
|
|
|
|> Map.put(:nonce, max_nil_last(first[:nonce], second[:nonce])) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|