block counter calculate only consensus block

pull/1838/head
saneery 6 years ago
parent a634f987a4
commit 878ca7222a
  1. 2
      apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex
  2. 15
      apps/explorer/lib/explorer/chain.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()

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

Loading…
Cancel
Save