|
|
@ -188,7 +188,7 @@ defmodule Explorer.Staking.ContractState do |
|
|
|
validators.all |
|
|
|
validators.all |
|
|
|
|> Enum.map(&ContractReader.staking_by_mining_requests/1) |
|
|
|
|> Enum.map(&ContractReader.staking_by_mining_requests/1) |
|
|
|
|> ContractReader.perform_grouped_requests(validators.all, contracts, abi) |
|
|
|
|> ContractReader.perform_grouped_requests(validators.all, contracts, abi) |
|
|
|
|> Map.new(fn {mining_address, resp} -> {mining_address, address_string_to_bytes(resp.staking_address)} end) |
|
|
|
|> Map.new(fn {mining_address, resp} -> {mining_address, address_string_to_bytes(resp.staking_address).bytes} end) |
|
|
|
|
|
|
|
|
|
|
|
# the list of all pools (validators + active pools + inactive pools) |
|
|
|
# the list of all pools (validators + active pools + inactive pools) |
|
|
|
pools = Enum.uniq( |
|
|
|
pools = Enum.uniq( |
|
|
@ -355,7 +355,7 @@ defmodule Explorer.Staking.ContractState do |
|
|
|
|
|
|
|
|
|
|
|
block_reward_balance = BalanceReader.get_balances_of([%{ |
|
|
|
block_reward_balance = BalanceReader.get_balances_of([%{ |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
address_hash: block_reward_address, |
|
|
|
address_hash: block_reward_address.bytes, |
|
|
|
block_number: block_number |
|
|
|
block_number: block_number |
|
|
|
}])[:ok] |
|
|
|
}])[:ok] |
|
|
|
|
|
|
|
|
|
|
@ -367,10 +367,10 @@ defmodule Explorer.Staking.ContractState do |
|
|
|
type: "ERC-20" |
|
|
|
type: "ERC-20" |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Chain.import(%{ |
|
|
|
import_result = Chain.import(%{ |
|
|
|
addresses: %{params: [%{hash: block_reward_address}], on_conflict: :nothing}, |
|
|
|
addresses: %{params: [%{hash: block_reward_address.bytes}], on_conflict: :nothing}, |
|
|
|
address_current_token_balances: %{params: [%{ |
|
|
|
address_current_token_balances: %{params: [%{ |
|
|
|
address_hash: block_reward_address, |
|
|
|
address_hash: block_reward_address.bytes, |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
token_contract_address_hash: token_contract_address_hash, |
|
|
|
block_number: block_number, |
|
|
|
block_number: block_number, |
|
|
|
value: block_reward_balance, |
|
|
|
value: block_reward_balance, |
|
|
@ -378,6 +378,15 @@ defmodule Explorer.Staking.ContractState do |
|
|
|
}]}, |
|
|
|
}]}, |
|
|
|
tokens: %{params: [token_params]} |
|
|
|
tokens: %{params: [token_params]} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with {:ok, _} <- import_result, do: |
|
|
|
|
|
|
|
Publisher.broadcast([{ |
|
|
|
|
|
|
|
:address_token_balances, [ |
|
|
|
|
|
|
|
%{address_hash: block_reward_address.struct, block_number: block_number} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}], |
|
|
|
|
|
|
|
:on_demand |
|
|
|
|
|
|
|
) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# start snapshotting at the beginning of the staking epoch |
|
|
|
# start snapshotting at the beginning of the staking epoch |
|
|
@ -431,10 +440,10 @@ defmodule Explorer.Staking.ContractState do |
|
|
|
%Chain.Hash{ |
|
|
|
%Chain.Hash{ |
|
|
|
byte_count: _, |
|
|
|
byte_count: _, |
|
|
|
bytes: bytes |
|
|
|
bytes: bytes |
|
|
|
} |
|
|
|
} = struct |
|
|
|
} = Chain.string_to_address_hash(address_string) |
|
|
|
} = Chain.string_to_address_hash(address_string) |
|
|
|
|
|
|
|
|
|
|
|
bytes |
|
|
|
%{bytes: bytes, struct: struct} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# sobelow_skip ["Traversal"] |
|
|
|
# sobelow_skip ["Traversal"] |
|
|
|