diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index e2bbd4ffe2..4efb0234f0 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -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. @@ -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. @@ -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()); @@ -755,7 +755,7 @@ pub struct AddedPendingTransaction { /// transactions promoted to the pending queue promoted: Vec>>, /// transaction that failed and became discarded - discarded: Vec, + discarded: Vec>>, } impl AddedPendingTransaction { @@ -871,7 +871,7 @@ pub(crate) struct OnNewCanonicalStateOutcome { /// Transactions promoted to the ready queue. pub(crate) promoted: Vec>>, /// transaction that were discarded during the update - pub(crate) discarded: Vec, + pub(crate) discarded: Vec>>, } impl OnNewCanonicalStateOutcome { diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index 8f8ba2de0f..29a6fa9e9e 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -416,8 +416,9 @@ impl TxPool { 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) => { @@ -1336,7 +1337,7 @@ pub(crate) struct UpdateOutcome { /// transactions promoted to the pending pool pub(crate) promoted: Vec>>, /// transaction that failed and were discarded - pub(crate) discarded: Vec, + pub(crate) discarded: Vec>>, } impl Default for UpdateOutcome {