use cache for estimated transaction count

pull/1634/head
Ayrat Badykov 6 years ago
parent 2ac34716b8
commit 8a58d4b03e
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 4
      apps/explorer/lib/explorer/application.ex
  2. 7
      apps/explorer/lib/explorer/chain.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()

@ -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 """

Loading…
Cancel
Save