From c97ce0c9d8c20f1da7f2a30c9673c79d48fc19f9 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Thu, 14 Feb 2019 14:33:15 -0500 Subject: [PATCH] feat: make replaced transactions disabled --- apps/indexer/config/config.exs | 2 ++ .../lib/indexer/replaced_transaction/fetcher.ex | 10 +++++++--- .../lib/indexer/replaced_transaction/supervisor.ex | 10 +++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index 55761ca60b..a0f9662ef7 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -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, diff --git a/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex b/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex index 805f3c830c..9a647e51b9 100644 --- a/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex +++ b/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex @@ -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,9 +32,12 @@ defmodule Indexer.ReplacedTransaction.Fetcher do } ]) :: :ok def async_fetch(transactions_fields, timeout \\ 5000) when is_list(transactions_fields) do - entries = Enum.map(transactions_fields, &entry/1) - - BufferedTask.buffer(__MODULE__, entries, timeout) + if ReplacedTransactionSupervisor.disabled?() do + :ok + else + entries = Enum.map(transactions_fields, &entry/1) + BufferedTask.buffer(__MODULE__, entries, timeout) + end end @doc false diff --git a/apps/indexer/lib/indexer/replaced_transaction/supervisor.ex b/apps/indexer/lib/indexer/replaced_transaction/supervisor.ex index f6e8e8b2f8..fc58f8f274 100644 --- a/apps/indexer/lib/indexer/replaced_transaction/supervisor.ex +++ b/apps/indexer/lib/indexer/replaced_transaction/supervisor.ex @@ -23,7 +23,15 @@ defmodule Indexer.ReplacedTransaction.Supervisor do end def start_link(arguments, gen_server_options \\ []) do - Supervisor.start_link(__MODULE__, arguments, Keyword.put_new(gen_server_options, :name, __MODULE__)) + 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