diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index ecf4250213..b896e84a1f 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -8,6 +8,7 @@ defmodule Explorer.Application do alias Explorer.Admin alias Explorer.Chain.BlockNumberCache alias Explorer.Repo.PrometheusLogger + alias Explorer.Chain.TransactionCountCache @impl Application def start(_type, _args) do @@ -27,7 +28,8 @@ defmodule Explorer.Application do Supervisor.child_spec({Task.Supervisor, name: Explorer.MarketTaskSupervisor}, id: Explorer.MarketTaskSupervisor), Supervisor.child_spec({Task.Supervisor, name: Explorer.TaskSupervisor}, id: Explorer.TaskSupervisor), {Registry, keys: :duplicate, name: Registry.ChainEvents, id: Registry.ChainEvents}, - {Admin.Recovery, [[], [name: Admin.Recovery]]} + {Admin.Recovery, [[], [name: Admin.Recovery]]}, + {TransactionCountCache, [[], []]} ] children = base_children ++ configurable_children() diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 58b6e1a34b..5bd6394606 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -20,7 +20,6 @@ defmodule Explorer.Chain do import EthereumJSONRPC, only: [integer_to_quantity: 1] - alias Ecto.Adapters.SQL alias Ecto.{Changeset, Multi} alias Explorer.Chain.{ @@ -39,6 +38,7 @@ defmodule Explorer.Chain do Token, TokenTransfer, Transaction, + TransactionCountCache, Wei } @@ -1842,10 +1842,7 @@ defmodule Explorer.Chain do """ @spec transaction_estimated_count() :: non_neg_integer() def transaction_estimated_count do - %Postgrex.Result{rows: [[rows]]} = - SQL.query!(Repo, "SELECT reltuples::BIGINT AS estimate FROM pg_class WHERE relname='transactions'") - - rows + TransactionCountCache.value() end @doc """