mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-23 22:28:13 -05:00
fix(txpool): also emit promoted pending tx on pool drift (#17695)
This commit is contained in:
@@ -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() }
|
||||
|
||||
@@ -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)
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user