Fetch balance only for blocks which are greatrer or equal block with FIRST_BLOCK number

pull/3126/head
Victor Baranov 5 years ago
parent 95c5856347
commit 4f591a5699
  1. 1
      CHANGELOG.md
  2. 22
      apps/indexer/lib/indexer/fetcher/coin_balance.ex

@ -3,6 +3,7 @@
### Features ### Features
### Fixes ### Fixes
- [#3126](https://github.com/poanetwork/blockscout/pull/3126) - Fetch balance only for blocks which are greater or equal block with FIRST_BLOCK number
- [#3122](https://github.com/poanetwork/blockscout/pull/3122) - Exclude balance percentage calculation for burn address on accounts page - [#3122](https://github.com/poanetwork/blockscout/pull/3122) - Exclude balance percentage calculation for burn address on accounts page
- [#3121](https://github.com/poanetwork/blockscout/pull/3121) - Geth: handle response from eth_getblockbyhash JSON RPC method without totalDifficulty (uncle blocks) - [#3121](https://github.com/poanetwork/blockscout/pull/3121) - Geth: handle response from eth_getblockbyhash JSON RPC method without totalDifficulty (uncle blocks)
- [#3119](https://github.com/poanetwork/blockscout/pull/3119), [#3120](https://github.com/poanetwork/blockscout/pull/3120) - Fix performance of Inventory tab loading for ERC-721 tokens - [#3119](https://github.com/poanetwork/blockscout/pull/3119), [#3120](https://github.com/poanetwork/blockscout/pull/3120) - Fix performance of Inventory tab loading for ERC-721 tokens

@ -77,17 +77,22 @@ defmodule Indexer.Fetcher.CoinBalance do
# `{address, block}`, so take unique params only # `{address, block}`, so take unique params only
unique_entries = Enum.uniq(entries) unique_entries = Enum.uniq(entries)
unique_entry_count = Enum.count(unique_entries) unique_filtered_entries =
Enum.filter(unique_entries, fn {_hash, block_number} ->
block_number >= first_block_to_index()
end)
unique_entry_count = Enum.count(unique_filtered_entries)
Logger.metadata(count: unique_entry_count) Logger.metadata(count: unique_entry_count)
Logger.debug(fn -> "fetching" end) Logger.debug(fn -> "fetching" end)
unique_entries unique_filtered_entries
|> Enum.map(&entry_to_params/1) |> Enum.map(&entry_to_params/1)
|> EthereumJSONRPC.fetch_balances(json_rpc_named_arguments) |> EthereumJSONRPC.fetch_balances(json_rpc_named_arguments)
|> case do |> case do
{:ok, fetched_balances} -> {:ok, fetched_balances} ->
run_fetched_balances(fetched_balances, unique_entries) run_fetched_balances(fetched_balances, unique_filtered_entries)
{:error, reason} -> {:error, reason} ->
Logger.error( Logger.error(
@ -97,7 +102,16 @@ defmodule Indexer.Fetcher.CoinBalance do
error_count: unique_entry_count error_count: unique_entry_count
) )
{:retry, unique_entries} {:retry, unique_filtered_entries}
end
end
defp first_block_to_index do
string_value = Application.get_env(:indexer, :first_block)
case Integer.parse(string_value) do
{integer, ""} -> integer
_ -> 0
end end
end end

Loading…
Cancel
Save