From dc2ea8d70ab5b370aab428ac0f890770eaf4a245 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Mon, 17 Oct 2022 16:38:05 +0300 Subject: [PATCH] Fix DISABLE_TOKEN_INSTANCE_FETCHER env --- apps/indexer/lib/indexer/fetcher/token_instance.ex | 10 ++++++++-- apps/indexer/lib/indexer/supervisor.ex | 9 +++++---- config/runtime.exs | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/indexer/lib/indexer/fetcher/token_instance.ex b/apps/indexer/lib/indexer/fetcher/token_instance.ex index f489652400..426dec162a 100644 --- a/apps/indexer/lib/indexer/fetcher/token_instance.ex +++ b/apps/indexer/lib/indexer/fetcher/token_instance.ex @@ -153,7 +153,13 @@ defmodule Indexer.Fetcher.TokenInstance do @doc """ Fetches token instance data asynchronously. """ - def async_fetch(token_transfers) when is_list(token_transfers) do + def async_fetch(data) do + async_fetch(data, __MODULE__.Supervisor.disabled?()) + end + + def async_fetch(_data, true), do: :ok + + def async_fetch(token_transfers, _disabled?) when is_list(token_transfers) do data = token_transfers |> Enum.reject(fn token_transfer -> is_nil(token_transfer.token_id) and is_nil(token_transfer.token_ids) end) @@ -169,7 +175,7 @@ defmodule Indexer.Fetcher.TokenInstance do BufferedTask.buffer(__MODULE__, data) end - def async_fetch(data) do + def async_fetch(data, _disabled?) do BufferedTask.buffer(__MODULE__, data) end end diff --git a/apps/indexer/lib/indexer/supervisor.ex b/apps/indexer/lib/indexer/supervisor.ex index 3d3e9bf43c..1980271c34 100644 --- a/apps/indexer/lib/indexer/supervisor.ex +++ b/apps/indexer/lib/indexer/supervisor.ex @@ -115,9 +115,10 @@ defmodule Indexer.Supervisor do {CoinBalance.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, {Token.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, - configure(TokenInstance.Supervisor, [ - [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] - ]), + {TokenInstance.Supervisor, + [ + [json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor] + ]}, {ContractCode.Supervisor, [[json_rpc_named_arguments: json_rpc_named_arguments, memory_monitor: memory_monitor]]}, {TokenBalance.Supervisor, @@ -148,7 +149,7 @@ defmodule Indexer.Supervisor do ) end - defp configure(process, opts \\ []) do + defp configure(process, opts) do if Application.get_env(:indexer, process)[:enabled] do [{process, opts}] else diff --git a/config/runtime.exs b/config/runtime.exs index 35e9810710..09091f0568 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -439,7 +439,7 @@ config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") config :indexer, Indexer.Block.Realtime.Supervisor, enabled: System.get_env("DISABLE_REALTIME_INDEXER") != "true" config :indexer, Indexer.Fetcher.TokenInstance.Supervisor, - enabled: System.get_env("DISABLE_TOKEN_INSTANCE_FETCHER") != "true" + disabled?: System.get_env("DISABLE_TOKEN_INSTANCE_FETCHER", "false") == "true" blocks_catchup_fetcher_batch_size_default_str = "10" blocks_catchup_fetcher_concurrency_default_str = "10"