Skip to content

Commit

Permalink
Manage BlockReward fetcher params
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov committed Feb 22, 2023
1 parent 28f5233 commit 9b1ebde
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
21 changes: 13 additions & 8 deletions apps/indexer/lib/indexer/fetcher/block_reward.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ defmodule Indexer.Fetcher.BlockReward do

@behaviour BufferedTask

@defaults [
flush_interval: :timer.seconds(3),
max_batch_size: 10,
max_concurrency: 4,
task_supervisor: Indexer.Fetcher.BlockReward.TaskSupervisor,
metadata: [fetcher: :block_reward]
]
@default_max_batch_size 10
@default_max_concurrency 4

@doc """
Asynchronously fetches block rewards for each `t:Explorer.Chain.Explorer.block_number/0`` in `block_numbers`.
Expand All @@ -57,7 +52,7 @@ defmodule Indexer.Fetcher.BlockReward do
end

merged_init_options =
@defaults
defaults()
|> Keyword.merge(mergeable_init_options)
|> Keyword.put(:state, state)

Expand Down Expand Up @@ -337,4 +332,14 @@ defmodule Indexer.Fetcher.BlockReward do
when is_integer(code) and is_binary(message) and is_binary(block_quantity) do
["@", quantity_to_integer(block_quantity), ": (", to_string(code), ") ", message, ?\n]
end

defp defaults do
[
flush_interval: :timer.seconds(3),
max_concurrency: Application.get_env(:indexer, __MODULE__)[:concurrency] || @default_max_concurrency,
max_batch_size: Application.get_env(:indexer, __MODULE__)[:batch_size] || @default_max_batch_size,
task_supervisor: Indexer.Fetcher.BlockReward.TaskSupervisor,
metadata: [fetcher: :block_reward]
]
end
end
8 changes: 8 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,14 @@ blocks_catchup_fetcher_missing_ranges_batch_size_default_str = "100000"
config :indexer, Indexer.Block.Catchup.MissingRangesCollector,
missing_ranges_batch_size: blocks_catchup_fetcher_missing_ranges_batch_size

{block_reward_fetcher_batch_size, _} = Integer.parse(System.get_env("INDEXER_BLOCK_REWARD_BATCH_SIZE", "10"))

{block_reward_fetcher_concurrency, _} = Integer.parse(System.get_env("INDEXER_BLOCK_REWARD_CONCURRENCY", "4"))

config :indexer, Indexer.Fetcher.BlockReward,
batch_size: block_reward_fetcher_batch_size,
concurrency: block_reward_fetcher_concurrency

{internal_transaction_fetcher_batch_size, _} =
Integer.parse(System.get_env("INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE", "10"))

Expand Down
2 changes: 2 additions & 0 deletions docker-compose/envs/common-blockscout.env
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=false
# INDEXER_CATCHUP_BLOCKS_CONCURRENCY=
# INDEXER_INTERNAL_TRANSACTIONS_BATCH_SIZE=
# INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY=
# INDEXER_BLOCK_REWARD_BATCH_SIZE=
# INDEXER_BLOCK_REWARD_CONCURRENCY=
# INDEXER_COIN_BALANCES_BATCH_SIZE=
# INDEXER_COIN_BALANCES_CONCURRENCY=
# INDEXER_RECEIPTS_BATCH_SIZE=
Expand Down
6 changes: 6 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ endif
ifdef INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY=$(INDEXER_INTERNAL_TRANSACTIONS_CONCURRENCY)'
endif
ifdef INDEXER_BLOCK_REWARD_BATCH_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_BLOCK_REWARD_BATCH_SIZE=$(INDEXER_BLOCK_REWARD_BATCH_SIZE)'
endif
ifdef INDEXER_BLOCK_REWARD_CONCURRENCY
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_BLOCK_REWARD_CONCURRENCY=$(INDEXER_BLOCK_REWARD_CONCURRENCY)'
endif
ifdef INDEXER_COIN_BALANCES_BATCH_SIZE
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_RECEIPTS_BATCH_SIZE=$(INDEXER_RECEIPTS_BATCH_SIZE)'
endif
Expand Down

0 comments on commit 9b1ebde

Please sign in to comment.