Merge pull request #1706 from poanetwork/ab-allow-setting-interval-for-addresses-with-balance-counter

allow setting update interval for addresses with balances counter
pull/1716/head
Ayrat Badykov 6 years ago committed by GitHub
commit df40eb4a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 13
      apps/explorer/config/config.exs
  3. 4
      apps/explorer/lib/explorer/counters/addresses_with_balance_counter.ex

@ -6,6 +6,7 @@
- [#1654](https://github.com/poanetwork/blockscout/pull/1654) - add decompiled code tab
- [#1661](https://github.com/poanetwork/blockscout/pull/1661) - try to compile smart contract with the latest evm version
- [#1665](https://github.com/poanetwork/blockscout/pull/1665) - Add contract verification RPC endpoint.
- [#1706](https://github.com/poanetwork/blockscout/pull/1706) - allow setting update interval for addresses with b
### Fixes

@ -13,7 +13,18 @@ config :explorer,
config :explorer, Explorer.Counters.AverageBlockTime, enabled: true
config :explorer, Explorer.Counters.AddressesWithBalanceCounter, enabled: true, enable_consolidation: true
balances_update_interval =
if System.get_env("ADDRESS_WITH_BALANCES_UPDATE_INTERVAL") do
case Integer.parse(System.get_env("ADDRESS_WITH_BALANCES_UPDATE_INTERVAL")) do
{integer, ""} -> integer
_ -> nil
end
end
config :explorer, Explorer.Counters.AddressesWithBalanceCounter,
enabled: true,
enable_consolidation: true,
update_interval_in_seconds: balances_update_interval || 30 * 60
config :explorer, Explorer.ExchangeRates, enabled: true, store: :ets

@ -29,6 +29,8 @@ defmodule Explorer.Counters.AddressesWithBalanceCounter do
config = Application.get_env(:explorer, Explorer.Counters.AddressesWithBalanceCounter)
@enable_consolidation Keyword.get(config, :enable_consolidation)
@update_interval_in_seconds Keyword.get(config, :update_interval_in_seconds)
@doc """
Starts a process to periodically update the counter of the token holders.
"""
@ -62,7 +64,7 @@ defmodule Explorer.Counters.AddressesWithBalanceCounter do
defp schedule_next_consolidation do
if enable_consolidation?() do
Process.send_after(self(), :consolidate, :timer.minutes(30))
Process.send_after(self(), :consolidate, :timer.seconds(@update_interval_in_seconds))
end
end

Loading…
Cancel
Save