diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index e49e499250..556cff6bba 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -11,7 +11,7 @@ defmodule BlockScoutWeb.ChainController do def show(conn, _params) do transaction_estimated_count = Chain.transaction_estimated_count() - block_count = Chain.block_count() + block_count = Chain.block_consensus_count() exchange_rate = Market.get_exchange_rate(Explorer.coin()) || Token.null() diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index b45e0d13e4..51d56fbf23 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -329,6 +329,21 @@ defmodule Explorer.Chain do Repo.aggregate(Block, :count, :hash) end + @doc """ + The number of consensus blocks. + + iex> insert(:block, consensus: true) + iex> insert(:block, consensus: false) + iex> Explorer.Chain.block_consensus_count() + 1 + + """ + def block_consensus_count do + Block + |> where(consensus: true) + |> Repo.aggregate(:count, :hash) + end + @doc """ Reward for mining a block.