Merge pull request #1445 from poanetwork/disable-replaced-transaction-fetcher

feat: make replaced transactions disabled
pull/1449/head
Andrew Cravenho 6 years ago committed by GitHub
commit 38dff27456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/indexer/config/config.exs
  2. 6
      apps/indexer/lib/indexer/replaced_transaction/fetcher.ex
  3. 8
      apps/indexer/lib/indexer/replaced_transaction/supervisor.ex

@ -35,6 +35,8 @@ config :indexer,
# bytes
memory_limit: 1 <<< 30
# config :indexer, Indexer.ReplacedTransaction.Supervisor, disabled?: true
config :indexer, Indexer.Tracer,
service: :indexer,
adapter: SpandexDatadog.Adapter,

@ -10,6 +10,7 @@ defmodule Indexer.ReplacedTransaction.Fetcher do
alias Explorer.Chain
alias Explorer.Chain.Hash
alias Indexer.{BufferedTask, Tracer}
alias Indexer.ReplacedTransaction.Supervisor, as: ReplacedTransactionSupervisor
@behaviour BufferedTask
@ -31,10 +32,13 @@ defmodule Indexer.ReplacedTransaction.Fetcher do
}
]) :: :ok
def async_fetch(transactions_fields, timeout \\ 5000) when is_list(transactions_fields) do
if ReplacedTransactionSupervisor.disabled?() do
:ok
else
entries = Enum.map(transactions_fields, &entry/1)
BufferedTask.buffer(__MODULE__, entries, timeout)
end
end
@doc false
def child_spec([init_options, gen_server_options]) do

@ -23,8 +23,16 @@ defmodule Indexer.ReplacedTransaction.Supervisor do
end
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__))
end
end
def disabled?() do
Application.get_env(:indexer, __MODULE__, [])[:disabled?] == true
end
@impl Supervisor
def init(fetcher_arguments) do

Loading…
Cancel
Save