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/pending_transaction_control...

36 lines
1.1 KiB

defmodule ExplorerWeb.PendingTransactionController do
use ExplorerWeb, :controller
import Ecto.Query
alias Explorer.Repo.NewRelic, as: Repo
alias Explorer.Transaction
alias Explorer.TransactionForm
def index(conn, params) do
query = from transaction in Transaction,
left_join: block_transaction in assoc(transaction, :block_transaction),
join: to_address_join in assoc(transaction, :to_address_join),
join: to_address in assoc(to_address_join, :address),
join: from_address_join in assoc(transaction, :from_address_join),
join: from_address in assoc(from_address_join, :address),
preload: [
to_address: to_address,
from_address: from_address
],
order_by: [desc: transaction.inserted_at],
where: is_nil(block_transaction.transaction_id)
transactions = query |> Repo.paginate(params)
render(
conn,
"index.html",
transactions:
transactions
|> Map.put(:entries, transactions.entries
|> Enum.map(&TransactionForm.build/1))
)
end
end