fix(txpool): also emit promoted pending tx on pool drift (#17695)

This commit is contained in:
Matthias Seitz
2025-07-31 20:54:44 +02:00
committed by GitHub
parent ed56417237
commit 3a2bf263d7
2 changed files with 21 additions and 0 deletions

View File

@@ -93,6 +93,13 @@ pub struct NewTransactionEvent<T: PoolTransaction> {
pub transaction: Arc<ValidPoolTransaction<T>>,
}
impl<T: PoolTransaction> NewTransactionEvent<T> {
/// Creates a new event for a pending transaction.
pub const fn pending(transaction: Arc<ValidPoolTransaction<T>>) -> Self {
Self { subpool: SubPool::Pending, transaction }
}
}
impl<T: PoolTransaction> Clone for NewTransactionEvent<T> {
fn clone(&self) -> Self {
Self { subpool: self.subpool, transaction: self.transaction.clone() }

View File

@@ -414,6 +414,8 @@ where
/// Performs account updates on the pool.
///
/// This will either promote or discard transactions based on the new account state.
///
/// This should be invoked when the pool drifted and accounts are updated manually
pub fn update_accounts(&self, accounts: Vec<ChangedAccount>) {
let changed_senders = self.changed_senders(accounts.into_iter());
let UpdateOutcome { promoted, discarded } =
@@ -431,6 +433,18 @@ where
});
listener.send_all(promoted_hashes)
});
// in this case we should also emit promoted transactions in full
self.transaction_listener.lock().retain_mut(|listener| {
let promoted_txs = promoted.iter().filter_map(|tx| {
if listener.kind.is_propagate_only() && !tx.propagate {
None
} else {
Some(NewTransactionEvent::pending(tx.clone()))
}
});
listener.send_all(promoted_txs)
});
}
{