Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/lib/explorer_web/controllers/chain_controller.ex

33 lines
801 B

defmodule ExplorerWeb.ChainController do
use ExplorerWeb, :controller
import Ecto.Query
alias Explorer.Block
alias Explorer.BlockForm
alias Explorer.Servers.ChainStatistics
alias Explorer.Repo.NewRelic, as: Repo
alias Explorer.Transaction
def show(conn, _params) do
blocks = from block in Block,
order_by: [desc: block.number],
preload: :transactions,
limit: 5
transactions = from transaction in Transaction,
join: block in assoc(transaction, :block),
order_by: [desc: block.number],
preload: [block: block],
limit: 5
render(
conn,
"show.html",
blocks: blocks |> Repo.all() |> Enum.map(&BlockForm.build/1),
transactions: transactions |> Repo.all(),
chain: ChainStatistics.fetch()
)
end
end