expose enable consolidation config

pull/973/head
Gustavo Santos Ferreira 6 years ago
parent b26745c993
commit 1cd5450252
  1. 5
      apps/explorer/lib/explorer/chain.ex
  2. 29
      apps/explorer/lib/explorer/counters/token_holders_counter.ex

@ -2079,6 +2079,11 @@ defmodule Explorer.Chain do
TokenHoldersCounter.fetch(contract_address_hash)
end
@spec token_holders_counter_consolidation_enabled? :: boolean()
def token_holders_counter_consolidation_enabled? do
TokenHoldersCounter.enable_consolidation?()
end
@spec address_to_unique_tokens(Hash.Address.t(), [paging_options]) :: [TokenTransfer.t()]
def address_to_unique_tokens(contract_address_hash, options \\ []) do
paging_options = Keyword.get(options, :paging_options, @default_paging_options)

@ -10,6 +10,11 @@ defmodule Explorer.Counters.TokenHoldersCounter do
@table :token_holders_counter
# It is undesirable to automatically start the consolidation in all environments.
# Consider the test environment: if the consolidation initiates but does not
# finish before a test ends, that test will fail. This way, hundreds of
# tests were failing before disabling the consolidation and the scheduler in
# the test env.
config = Application.get_env(:explorer, Explorer.Counters.TokenHoldersCounter)
@enable_consolidation Keyword.get(config, :enable_consolidation)
@ -94,15 +99,17 @@ defmodule Explorer.Counters.TokenHoldersCounter do
{:noreply, state}
end
# We don't want to automatically start the consolidation in all environments.
# Consider the test environment: if the consolidation initiates but does not
# finishes before a test ends, that test will fail. This way, hundreds o
# tests were failing before disabling the consolidation and the scheduler in
# the test env.
#
# In order to choose whether or not to enable the scheduler and the initial
# consolidation, change the following Explorer config:
#
# config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: false
defp enable_consolidation?, do: @enable_consolidation
@doc """
Returns a boolean that indicates whether consolidation is enabled
In order to choose whether or not to enable the scheduler and the initial
consolidation, change the following Explorer config:
`config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: true`
to:
`config :explorer, Explorer.Counters.TokenHoldersCounter, enable_consolidation: false`
"""
def enable_consolidation?, do: @enable_consolidation
end

Loading…
Cancel
Save