Merge branch 'master' into realtime-separate-node-configuration

pull/1567/head
Victor Baranov 6 years ago committed by GitHub
commit 7c2c85182d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      apps/indexer/config/config.exs
  2. 5
      apps/indexer/lib/indexer/block/reward/fetcher.ex
  3. 8
      apps/indexer/lib/indexer/block/reward/supervisor.ex

@ -36,6 +36,7 @@ config :indexer,
memory_limit: 1 <<< 30 memory_limit: 1 <<< 30
# config :indexer, Indexer.ReplacedTransaction.Supervisor, disabled?: true # config :indexer, Indexer.ReplacedTransaction.Supervisor, disabled?: true
# config :indexer, Indexer.Block.Reward.Supervisor, disabled?: true
config :indexer, Indexer.Tracer, config :indexer, Indexer.Tracer,
service: :indexer, service: :indexer,

@ -18,6 +18,7 @@ defmodule Indexer.Block.Reward.Fetcher do
alias Explorer.Chain.{Block, Wei} alias Explorer.Chain.{Block, Wei}
alias Indexer.Address.CoinBalances alias Indexer.Address.CoinBalances
alias Indexer.{AddressExtraction, BufferedTask, CoinBalance, Tracer} alias Indexer.{AddressExtraction, BufferedTask, CoinBalance, Tracer}
alias Indexer.Block.Reward.Supervisor, as: BlockRewardSupervisor
@behaviour BufferedTask @behaviour BufferedTask
@ -34,8 +35,12 @@ defmodule Indexer.Block.Reward.Fetcher do
""" """
@spec async_fetch([Block.block_number()]) :: :ok @spec async_fetch([Block.block_number()]) :: :ok
def async_fetch(block_numbers) when is_list(block_numbers) do def async_fetch(block_numbers) when is_list(block_numbers) do
if BlockRewardSupervisor.disabled?() do
:ok
else
BufferedTask.buffer(__MODULE__, block_numbers) BufferedTask.buffer(__MODULE__, block_numbers)
end end
end
@doc false @doc false
# credo:disable-for-next-line Credo.Check.Design.DuplicatedCode # credo:disable-for-next-line Credo.Check.Design.DuplicatedCode

@ -22,8 +22,16 @@ defmodule Indexer.Block.Reward.Supervisor do
end end
def start_link(arguments, gen_server_options \\ []) do def start_link(arguments, gen_server_options \\ []) do
if disabled?() do
:ignore
else
Supervisor.start_link(__MODULE__, arguments, Keyword.put_new(gen_server_options, :name, __MODULE__)) Supervisor.start_link(__MODULE__, arguments, Keyword.put_new(gen_server_options, :name, __MODULE__))
end end
end
def disabled?() do
Application.get_env(:indexer, __MODULE__, [])[:disabled?] == true
end
@impl Supervisor @impl Supervisor
def init(fetcher_arguments) do def init(fetcher_arguments) do

Loading…
Cancel
Save