Merge pull request #1614 from poanetwork/ab-do-not-fetch-burn-address-balance

do not fetch burn address balance
pull/1627/head
Victor Baranov 6 years ago committed by GitHub
commit 03e2bcd0d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 26
      apps/indexer/lib/indexer/address/token_balances.ex
  3. 5
      apps/indexer/test/indexer/address/token_balances_test.exs

@ -4,6 +4,8 @@
### Fixes ### Fixes
- [1614](https://github.com/poanetwork/blockscout/pull/1614) - Do not fetch burn address token balance
### Chore ### Chore

@ -3,6 +3,8 @@ defmodule Indexer.Address.TokenBalances do
Extracts `Explorer.Address.TokenBalance` params from other schema's params. Extracts `Explorer.Address.TokenBalance` params from other schema's params.
""" """
@burn_address "0x0000000000000000000000000000000000000000"
def params_set(%{} = import_options) do def params_set(%{} = import_options) do
Enum.reduce(import_options, MapSet.new(), &reducer/2) Enum.reduce(import_options, MapSet.new(), &reducer/2)
end end
@ -20,16 +22,8 @@ defmodule Indexer.Address.TokenBalances do
when is_integer(block_number) and is_binary(from_address_hash) and when is_integer(block_number) and is_binary(from_address_hash) and
is_binary(to_address_hash) and is_binary(token_contract_address_hash) -> is_binary(to_address_hash) and is_binary(token_contract_address_hash) ->
acc acc
|> MapSet.put(%{ |> add_token_balance_address(from_address_hash, token_contract_address_hash, block_number)
address_hash: from_address_hash, |> add_token_balance_address(to_address_hash, token_contract_address_hash, block_number)
token_contract_address_hash: token_contract_address_hash,
block_number: block_number
})
|> MapSet.put(%{
address_hash: to_address_hash,
token_contract_address_hash: token_contract_address_hash,
block_number: block_number
})
end) end)
end end
@ -37,7 +31,17 @@ defmodule Indexer.Address.TokenBalances do
Enum.filter(token_transfers_params, &do_filter_burn_address/1) Enum.filter(token_transfers_params, &do_filter_burn_address/1)
end end
def do_filter_burn_address(%{to_address_hash: "0x0000000000000000000000000000000000000000", token_type: "ERC-721"}) do defp add_token_balance_address(map_set, unquote(@burn_address), _, _), do: map_set
defp add_token_balance_address(map_set, address, token_contract_address, block_number) do
MapSet.put(map_set, %{
address_hash: address,
token_contract_address_hash: token_contract_address,
block_number: block_number
})
end
def do_filter_burn_address(%{to_address_hash: unquote(@burn_address), token_type: "ERC-721"}) do
false false
end end

@ -53,11 +53,6 @@ defmodule Indexer.Address.TokenBalancesTest do
assert params_set == assert params_set ==
MapSet.new([ MapSet.new([
%{
address_hash: "0x0000000000000000000000000000000000000000",
block_number: 1,
token_contract_address_hash: "0xe18035bf8712672935fdb4e5e431b1a0183d2dfc"
},
%{ %{
address_hash: "0x5b8410f67eb8040bb1cd1e8a4ff9d5f6ce678a15", address_hash: "0x5b8410f67eb8040bb1cd1e8a4ff9d5f6ce678a15",
block_number: 1, block_number: 1,

Loading…
Cancel
Save