exclude replaced transaction from pending transactions list

pull/1370/head
Ayrat Badykov 6 years ago
parent 944e953351
commit fb597cd6e3
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 12
      apps/explorer/lib/explorer/chain.ex

@ -1164,7 +1164,7 @@ defmodule Explorer.Chain do
query =
from(
t in Transaction,
# exclude pending transactions
# exclude pending transactions and replaced transactions
where: not is_nil(t.block_hash) and is_nil(t.internal_transactions_indexed_at),
select: ^fields
)
@ -1474,7 +1474,7 @@ defmodule Explorer.Chain do
@spec pending_transaction_count() :: non_neg_integer()
def pending_transaction_count do
Transaction
|> where([transaction], is_nil(transaction.block_hash))
|> pending_transactions_query()
|> Repo.aggregate(:count, :hash)
end
@ -1547,13 +1547,19 @@ defmodule Explorer.Chain do
Transaction
|> page_pending_transaction(paging_options)
|> limit(^paging_options.page_size)
|> where([transaction], is_nil(transaction.block_hash))
|> pending_transactions_query()
|> order_by([transaction], desc: transaction.inserted_at, desc: transaction.hash)
|> join_associations(necessity_by_association)
|> preload([{:token_transfers, [:token, :from_address, :to_address]}])
|> Repo.all()
end
defp pending_transactions_query(query) do
from(transaction in query,
where: is_nil(transaction.block_hash) and is_nil(transaction.error)
)
end
@doc """
The `string` must start with `0x`, then is converted to an integer and then to `t:Explorer.Chain.Hash.Address.t/0`.

Loading…
Cancel
Save