fix: Fix bug in update_replaced_transactions query (#10634)

* fix: Fix bug in update_replaced_transactions query

* Fix condition for error
vb-dockerfile-nonroot-only
Victor Baranov 3 months ago committed by GitHub
parent e7f14c3dcd
commit 8a65bb0470
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 24
      apps/explorer/lib/explorer/chain.ex

@ -2738,19 +2738,23 @@ defmodule Explorer.Chain do
|> select_repo(options).all()
end
@doc """
Query to return all pending transactions
"""
@spec pending_transactions_query(Ecto.Queryable.t()) :: Ecto.Queryable.t()
def pending_transactions_query(query) do
from(transaction in query,
where: is_nil(transaction.block_hash) and (is_nil(transaction.error) or transaction.error != "dropped/replaced")
)
end
@doc """
Returns pending transactions list from the DB
"""
@spec pending_transactions_list() :: Ecto.Schema.t() | term()
def pending_transactions_list do
query =
from(transaction in Transaction,
where: is_nil(transaction.block_hash) and (is_nil(transaction.error) or transaction.error != "dropped/replaced")
)
query
Transaction
|> pending_transactions_query()
|> Repo.all(timeout: :infinity)
end
@ -3877,13 +3881,17 @@ defmodule Explorer.Chain do
|> Enum.uniq()
if Enum.empty?(filters) do
{:ok, []}
{0, []}
else
query =
filters
|> Enum.reduce(Transaction, fn {nonce, from_address}, query ->
from(t in query,
or_where: t.nonce == ^nonce and t.from_address_hash == ^from_address and is_nil(t.block_hash)
or_where:
t.nonce == ^nonce and
t.from_address_hash == ^from_address and
is_nil(t.block_hash) and
(is_nil(t.error) or t.error != "dropped/replaced")
)
end)
# Enforce Transaction ShareLocks order (see docs: sharelocks.md)

Loading…
Cancel
Save