Merge pull request #3870 from blockscout/vb-manage-token-balance-update-threshold

Manage token balance on-demand fetcher threshold via env var
pull/3881/head
Victor Baranov 4 years ago committed by GitHub
commit aa3d5b5e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 12
      apps/indexer/config/config.exs
  3. 4
      apps/indexer/lib/indexer/fetcher/token_balance_on_demand.ex

@ -5,6 +5,7 @@
### Fixes
### Chore
- [#3870](https://github.com/blockscout/blockscout/pull/3870) - Manage token balance on-demand fetcher threshold via env var
## 3.7.0-beta

@ -41,6 +41,18 @@ config :indexer,
config :indexer, Indexer.Fetcher.PendingTransaction.Supervisor,
disabled?: System.get_env("ETHEREUM_JSONRPC_VARIANT") == "besu"
token_balance_on_demand_fetcher_threshold =
if System.get_env("TOKEN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES") do
case Integer.parse(System.get_env("TOKEN_BALANCE_ON_DEMAND_FETCHER_THRESHOLD_MINUTES")) do
{integer, ""} -> integer
_ -> 60
end
else
60
end
config :indexer, Indexer.Fetcher.TokenBalanceOnDemand, threshold: token_balance_on_demand_fetcher_threshold
# config :indexer, Indexer.Fetcher.ReplacedTransaction.Supervisor, disabled?: true
if System.get_env("POS_STAKING_CONTRACT") do
config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: true

@ -4,8 +4,6 @@ defmodule Indexer.Fetcher.TokenBalanceOnDemand do
"""
@latest_balance_stale_threshold :timer.hours(24)
use Indexer.Fetcher
alias Explorer.Chain
@ -105,7 +103,7 @@ defmodule Indexer.Fetcher.TokenBalanceOnDemand do
if average_block_time == 0 do
{:error, :empty_database}
else
block_number - div(@latest_balance_stale_threshold, average_block_time)
block_number - div(:timer.minutes(Application.get_env(:indexer, __MODULE__)[:threshold]), average_block_time)
end
end
end

Loading…
Cancel
Save