diff --git a/apps/indexer/config/dev/parity.exs b/apps/indexer/config/dev/parity.exs index bdda087359..d6e300f077 100644 --- a/apps/indexer/config/dev/parity.exs +++ b/apps/indexer/config/dev/parity.exs @@ -16,6 +16,23 @@ config :indexer, ], variant: EthereumJSONRPC.Parity ], + # Example configuration to override json_rpc_named_arguments for just the realtime block fetcher + # realtime_overrides: [ + # json_rpc_named_arguments: [ + # transport: EthereumJSONRPC.HTTP, + # transport_options: [ + # http: EthereumJSONRPC.HTTP.HTTPoison, + # url: System.get_env("ETHEREUM_JSONRPC_REALTIME_HTTP_URL") || "http://localhost:8545", + # method_to_url: [ + # eth_getBalance: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545", + # trace_block: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545", + # trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545" + # ], + # http_options: [recv_timeout: :timer.minutes(1), timeout: :timer.minutes(1), hackney: [pool: :ethereum_jsonrpc]] + # ], + # variant: EthereumJSONRPC.Parity + # ] + # ], subscribe_named_arguments: [ transport: EthereumJSONRPC.WebSocket, transport_options: [ diff --git a/apps/indexer/lib/indexer/block/supervisor.ex b/apps/indexer/lib/indexer/block/supervisor.ex index 6365aba2d7..d77960c503 100644 --- a/apps/indexer/lib/indexer/block/supervisor.ex +++ b/apps/indexer/lib/indexer/block/supervisor.ex @@ -18,14 +18,23 @@ defmodule Indexer.Block.Supervisor do %{ block_interval: block_interval, json_rpc_named_arguments: json_rpc_named_arguments, - subscribe_named_arguments: subscribe_named_arguments + subscribe_named_arguments: subscribe_named_arguments, + realtime_overrides: realtime_overrides } = named_arguments ) do block_fetcher = named_arguments - |> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments)a) + |> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments realtime_overrides)a) |> Block.Fetcher.new() + realtime_block_fetcher = + named_arguments + |> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments realtime_overrides)a) + |> Map.merge(Enum.into(realtime_overrides, %{})) + |> Block.Fetcher.new() + + realtime_subscribe_named_arguments = realtime_overrides[:subscribe_named_arguments] || subscribe_named_arguments + memory_monitor = Map.get(named_arguments, :memory_monitor) Supervisor.init( @@ -38,7 +47,7 @@ defmodule Indexer.Block.Supervisor do {InvalidConsensus.Supervisor, [[], [name: InvalidConsensus.Supervisor]]}, {Realtime.Supervisor, [ - %{block_fetcher: block_fetcher, subscribe_named_arguments: subscribe_named_arguments}, + %{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments}, [name: Realtime.Supervisor] ]}, {Uncle.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor], [name: Uncle.Supervisor]]}, diff --git a/apps/indexer/lib/indexer/shrinkable/supervisor.ex b/apps/indexer/lib/indexer/shrinkable/supervisor.ex index e4b6693c40..6135b7f9e0 100644 --- a/apps/indexer/lib/indexer/shrinkable/supervisor.ex +++ b/apps/indexer/lib/indexer/shrinkable/supervisor.ex @@ -48,10 +48,11 @@ defmodule Indexer.Shrinkable.Supervisor do |> Application.get_all_env() |> Keyword.take( ~w(blocks_batch_size blocks_concurrency block_interval json_rpc_named_arguments receipts_batch_size - receipts_concurrency subscribe_named_arguments)a + receipts_concurrency subscribe_named_arguments realtime_overrides)a ) |> Enum.into(%{}) |> Map.put(:memory_monitor, memory_monitor) + |> Map.put_new(:realtime_overrides, %{}) Supervisor.init( [