From 699b42a1b302740317febfe081d5699e1f47404c Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Fri, 1 Apr 2022 15:10:45 +0400 Subject: [PATCH] Ability to disable block reward, coin balance, token updater fetchers --- apps/indexer/config/config.exs | 9 ++++++++- apps/indexer/lib/indexer/fetcher/coin_balance.ex | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/indexer/config/config.exs b/apps/indexer/config/config.exs index 225fe6978a..0a98071f2b 100644 --- a/apps/indexer/config/config.exs +++ b/apps/indexer/config/config.exs @@ -69,12 +69,19 @@ config :indexer, Indexer.Fetcher.CoinBalanceOnDemand, threshold: coin_balance_on if System.get_env("POS_STAKING_CONTRACT") do config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: true else - config :indexer, Indexer.Fetcher.BlockReward.Supervisor, disabled?: false + config :indexer, Indexer.Fetcher.BlockReward.Supervisor, + disabled?: System.get_env("INDEXER_DISABLE_BLOCK_REWARD_FETCHER", "false") == "true" end config :indexer, Indexer.Fetcher.InternalTransaction.Supervisor, disabled?: System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true" +config :indexer, Indexer.Fetcher.CoinBalance.Supervisor, + disabled?: System.get_env("INDEXER_DISABLE_ADDRESS_COIN_BALANCE_FETCHER", "false") == "true" + +config :indexer, Indexer.Fetcher.TokenUpdater.Supervisor, + disabled?: System.get_env("INDEXER_DISABLE_CATALOGED_TOKEN_UPDATER_FETCHER", "false") == "true" + config :indexer, Indexer.Supervisor, enabled: System.get_env("DISABLE_INDEXER") != "true" config :indexer, Indexer.Tracer, diff --git a/apps/indexer/lib/indexer/fetcher/coin_balance.ex b/apps/indexer/lib/indexer/fetcher/coin_balance.ex index 02ddbd2917..94ace2f431 100644 --- a/apps/indexer/lib/indexer/fetcher/coin_balance.ex +++ b/apps/indexer/lib/indexer/fetcher/coin_balance.ex @@ -16,6 +16,7 @@ defmodule Indexer.Fetcher.CoinBalance do alias Explorer.Chain.{Block, Hash} alias Explorer.Chain.Cache.Accounts alias Indexer.{BufferedTask, Tracer} + alias Indexer.Fetcher.CoinBalance.Supervisor, as: CoinBalanceSupervisor @behaviour BufferedTask @@ -34,9 +35,13 @@ defmodule Indexer.Fetcher.CoinBalance do %{required(:address_hash) => Hash.Address.t(), required(:block_number) => Block.block_number()} ]) :: :ok def async_fetch_balances(balance_fields) when is_list(balance_fields) do - entries = Enum.map(balance_fields, &entry/1) + if CoinBalanceSupervisor.disabled?() do + :ok + else + entries = Enum.map(balance_fields, &entry/1) - BufferedTask.buffer(__MODULE__, entries) + BufferedTask.buffer(__MODULE__, entries) + end end @doc false