diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index e6114e7e36..29dbda3e95 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -204,9 +204,15 @@ where pub fn block_info(&self) -> BlockInfo { self.get_pool_data().block_info() } - /// Sets the currently tracked block + /// Sets the currently tracked block. + /// + /// This will also notify subscribers about any transactions that were promoted to the pending + /// pool due to fee changes. pub fn set_block_info(&self, info: BlockInfo) { - self.pool.write().set_block_info(info) + let outcome = self.pool.write().set_block_info(info); + + // Notify subscribers about promoted transactions due to fee changes + self.notify_on_transaction_updates(outcome.promoted, outcome.discarded); } /// Returns the internal [`SenderId`] for this address diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index 40f3e2c64b..27565ba188 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -351,15 +351,25 @@ impl TxPool { /// Sets the current block info for the pool. /// - /// This will also apply updates to the pool based on the new base fee and blob fee - pub fn set_block_info(&mut self, info: BlockInfo) { - // first update the subpools based on the new values - let basefee_ordering = self.update_basefee(info.pending_basefee, |_| {}); + /// This will also apply updates to the pool based on the new base fee and blob fee. + /// + /// Returns the outcome containing any transactions that were promoted due to fee changes. + pub fn set_block_info(&mut self, info: BlockInfo) -> UpdateOutcome { + let mut outcome = UpdateOutcome::default(); + + // first update the subpools based on the new values, collecting promoted transactions + let basefee_ordering = self.update_basefee(info.pending_basefee, |tx| { + outcome.promoted.push(tx.clone()); + }); if let Some(blob_fee) = info.pending_blob_fee { - self.update_blob_fee(blob_fee, basefee_ordering, |_| {}) + self.update_blob_fee(blob_fee, basefee_ordering, |tx| { + outcome.promoted.push(tx.clone()); + }) } // then update tracked values self.all_transactions.set_block_info(info); + + outcome } /// Returns an iterator that yields transactions that are ready to be included in the block with diff --git a/crates/transaction-pool/src/pool/update.rs b/crates/transaction-pool/src/pool/update.rs index 2322ccf6e6..851c017b20 100644 --- a/crates/transaction-pool/src/pool/update.rs +++ b/crates/transaction-pool/src/pool/update.rs @@ -35,11 +35,11 @@ impl From for Destination { /// Tracks the result after updating the pool #[derive(Debug)] -pub(crate) struct UpdateOutcome { +pub struct UpdateOutcome { /// transactions promoted to the pending pool - pub(crate) promoted: Vec>>, + pub promoted: Vec>>, /// transaction that failed and were discarded - pub(crate) discarded: Vec>>, + pub discarded: Vec>>, } impl Default for UpdateOutcome {