Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: collect full discarded tx #4353

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ where
let mut listener = self.event_listener.write();

promoted.iter().for_each(|tx| listener.pending(tx.hash(), None));
discarded.iter().for_each(|tx| listener.discarded(tx));
discarded.iter().for_each(|tx| listener.discarded(tx.hash()));
}

/// Add a single validated transaction into the pool.
Expand Down Expand Up @@ -568,7 +568,7 @@ where

mined.iter().for_each(|tx| listener.mined(tx, block_hash));
promoted.iter().for_each(|tx| listener.pending(tx.hash(), None));
discarded.iter().for_each(|tx| listener.discarded(tx));
discarded.iter().for_each(|tx| listener.discarded(tx.hash()));
}

/// Fire events for the newly added transaction if there are any.
Expand All @@ -581,7 +581,7 @@ where

listener.pending(transaction.hash(), replaced.clone());
promoted.iter().for_each(|tx| listener.pending(tx.hash(), None));
discarded.iter().for_each(|tx| listener.discarded(tx));
discarded.iter().for_each(|tx| listener.discarded(tx.hash()));
}
AddedTransaction::Parked { transaction, replaced, .. } => {
listener.queued(transaction.hash());
Expand Down Expand Up @@ -755,7 +755,7 @@ pub struct AddedPendingTransaction<T: PoolTransaction> {
/// transactions promoted to the pending queue
promoted: Vec<Arc<ValidPoolTransaction<T>>>,
/// transaction that failed and became discarded
discarded: Vec<TxHash>,
discarded: Vec<Arc<ValidPoolTransaction<T>>>,
}

impl<T: PoolTransaction> AddedPendingTransaction<T> {
Expand Down Expand Up @@ -871,7 +871,7 @@ pub(crate) struct OnNewCanonicalStateOutcome<T: PoolTransaction> {
/// Transactions promoted to the ready queue.
pub(crate) promoted: Vec<Arc<ValidPoolTransaction<T>>>,
/// transaction that were discarded during the update
pub(crate) discarded: Vec<TxHash>,
pub(crate) discarded: Vec<Arc<ValidPoolTransaction<T>>>,
}

impl<T: PoolTransaction> OnNewCanonicalStateOutcome<T> {
Expand Down
7 changes: 4 additions & 3 deletions crates/transaction-pool/src/pool/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ impl<T: TransactionOrdering> TxPool<T> {
match destination {
Destination::Discard => {
// remove the transaction from the pool and subpool
self.prune_transaction_by_hash(&hash);
outcome.discarded.push(hash);
if let Some(tx) = self.prune_transaction_by_hash(&hash) {
outcome.discarded.push(tx);
}
self.metrics.removed_transactions.increment(1);
}
Destination::Pool(move_to) => {
Expand Down Expand Up @@ -1336,7 +1337,7 @@ pub(crate) struct UpdateOutcome<T: PoolTransaction> {
/// transactions promoted to the pending pool
pub(crate) promoted: Vec<Arc<ValidPoolTransaction<T>>>,
/// transaction that failed and were discarded
pub(crate) discarded: Vec<TxHash>,
pub(crate) discarded: Vec<Arc<ValidPoolTransaction<T>>>,
}

impl<T: PoolTransaction> Default for UpdateOutcome<T> {
Expand Down
Loading