|
|
@ -64,19 +64,26 @@ defmodule Indexer.Transform.AddressCoinBalancesDaily do |
|
|
|
|
|
|
|
|
|
|
|
block_timestamp_map = |
|
|
|
block_timestamp_map = |
|
|
|
Enum.reduce(block_numbers, %{}, fn block_number, map -> |
|
|
|
Enum.reduce(block_numbers, %{}, fn block_number, map -> |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: timestamp}]}} = |
|
|
|
case EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) do |
|
|
|
EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: timestamp}]}} -> |
|
|
|
|
|
|
|
|
|
|
|
day = DateTime.to_date(timestamp) |
|
|
|
day = DateTime.to_date(timestamp) |
|
|
|
Map.put(map, "#{block_number}", day) |
|
|
|
Map.put(map, "#{block_number}", day) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
|
|
|
|
map |
|
|
|
|
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
logs_params |
|
|
|
logs_params |
|
|
|
|> Enum.into(acc, fn |
|
|
|
|> Enum.into(acc, fn |
|
|
|
%{address_hash: address_hash, block_number: block_number} |
|
|
|
%{address_hash: address_hash, block_number: block_number} |
|
|
|
when is_binary(address_hash) and is_integer(block_number) -> |
|
|
|
when is_binary(address_hash) and is_integer(block_number) -> |
|
|
|
|
|
|
|
if Map.has_key?(block_timestamp_map, "#{block_number}") do |
|
|
|
day = Map.get(block_timestamp_map, "#{block_number}") |
|
|
|
day = Map.get(block_timestamp_map, "#{block_number}") |
|
|
|
%{address_hash: address_hash, day: day} |
|
|
|
%{address_hash: address_hash, day: day} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
%{type: "pending"} -> |
|
|
|
%{type: "pending"} -> |
|
|
|
nil |
|
|
|
nil |
|
|
@ -137,9 +144,8 @@ defmodule Indexer.Transform.AddressCoinBalancesDaily do |
|
|
|
# a transaction MUST have a `from_address_hash` |
|
|
|
# a transaction MUST have a `from_address_hash` |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: block_timestamp}]}} = |
|
|
|
case EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) do |
|
|
|
EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: block_timestamp}]}} -> |
|
|
|
|
|
|
|
|
|
|
|
day = DateTime.to_date(block_timestamp) |
|
|
|
day = DateTime.to_date(block_timestamp) |
|
|
|
acc = MapSet.put(initial, %{address_hash: from_address_hash, day: day}) |
|
|
|
acc = MapSet.put(initial, %{address_hash: from_address_hash, day: day}) |
|
|
|
|
|
|
|
|
|
|
@ -151,5 +157,9 @@ defmodule Indexer.Transform.AddressCoinBalancesDaily do |
|
|
|
_ -> |
|
|
|
_ -> |
|
|
|
acc |
|
|
|
acc |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
|
|
|
|
initial |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|