Skip to content

Commit e03c9da

Browse files
authored
refactor: remove unused add_transactions_with_origins trait (#19824)
1 parent ee63c7d commit e03c9da

File tree

4 files changed

+6
-73
lines changed

4 files changed

+6
-73
lines changed

crates/transaction-pool/src/lib.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -384,23 +384,6 @@ where
384384
self.pool.validator().validate_transactions_with_origin(origin, transactions).await
385385
}
386386

387-
/// Validates all transactions with their individual origins.
388-
///
389-
/// This returns the validated transactions in the same order as input.
390-
async fn validate_all_with_origins(
391-
&self,
392-
transactions: Vec<(TransactionOrigin, V::Transaction)>,
393-
) -> Vec<(TransactionOrigin, TransactionValidationOutcome<V::Transaction>)> {
394-
if transactions.len() == 1 {
395-
let (origin, tx) = transactions.into_iter().next().unwrap();
396-
let res = self.pool.validator().validate_transaction(origin, tx).await;
397-
return vec![(origin, res)]
398-
}
399-
let origins: Vec<_> = transactions.iter().map(|(origin, _)| *origin).collect();
400-
let tx_outcomes = self.pool.validator().validate_transactions(transactions).await;
401-
origins.into_iter().zip(tx_outcomes).collect()
402-
}
403-
404387
/// Number of transactions in the entire pool
405388
pub fn len(&self) -> usize {
406389
self.pool.len()
@@ -516,18 +499,6 @@ where
516499
self.pool.add_transactions(origin, validated.into_iter())
517500
}
518501

519-
async fn add_transactions_with_origins(
520-
&self,
521-
transactions: Vec<(TransactionOrigin, Self::Transaction)>,
522-
) -> Vec<PoolResult<AddedTransactionOutcome>> {
523-
if transactions.is_empty() {
524-
return Vec::new()
525-
}
526-
let validated = self.validate_all_with_origins(transactions).await;
527-
528-
self.pool.add_transactions_with_origins(validated)
529-
}
530-
531502
fn transaction_event_listener(&self, tx_hash: TxHash) -> Option<TransactionEvents> {
532503
self.pool.add_transaction_event_listener(tx_hash)
533504
}

crates/transaction-pool/src/noop.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,6 @@ impl<T: EthPoolTransaction> TransactionPool for NoopTransactionPool<T> {
9898
.collect()
9999
}
100100

101-
async fn add_transactions_with_origins(
102-
&self,
103-
transactions: Vec<(TransactionOrigin, Self::Transaction)>,
104-
) -> Vec<PoolResult<AddedTransactionOutcome>> {
105-
transactions
106-
.into_iter()
107-
.map(|(_, transaction)| {
108-
let hash = *transaction.hash();
109-
Err(PoolError::other(hash, Box::new(NoopInsertError::new(transaction))))
110-
})
111-
.collect()
112-
}
113-
114101
fn transaction_event_listener(&self, _tx_hash: TxHash) -> Option<TransactionEvents> {
115102
None
116103
}

crates/transaction-pool/src/pool/mod.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -571,24 +571,22 @@ where
571571
Ok(listener)
572572
}
573573

574-
/// Adds all transactions in the iterator to the pool, each with its individual origin,
575-
/// returning a list of results.
574+
/// Adds all transactions in the iterator to the pool, returning a list of results.
576575
///
577576
/// Note: A large batch may lock the pool for a long time that blocks important operations
578577
/// like updating the pool on canonical state changes. The caller should consider having
579578
/// a max batch size to balance transaction insertions with other updates.
580-
pub fn add_transactions_with_origins(
579+
pub fn add_transactions(
581580
&self,
582-
transactions: impl IntoIterator<
583-
Item = (TransactionOrigin, TransactionValidationOutcome<T::Transaction>),
584-
>,
581+
origin: TransactionOrigin,
582+
transactions: impl IntoIterator<Item = TransactionValidationOutcome<T::Transaction>>,
585583
) -> Vec<PoolResult<AddedTransactionOutcome>> {
586584
// Process all transactions in one write lock, maintaining individual origins
587585
let (mut added, discarded) = {
588586
let mut pool = self.pool.write();
589587
let added = transactions
590588
.into_iter()
591-
.map(|(origin, tx)| self.add_transaction(&mut pool, origin, tx))
589+
.map(|tx| self.add_transaction(&mut pool, origin, tx))
592590
.collect::<Vec<_>>();
593591

594592
// Enforce the pool size limits if at least one transaction was added successfully
@@ -618,24 +616,11 @@ where
618616
*res = Err(PoolError::new(*hash, PoolErrorKind::DiscardedOnInsert))
619617
}
620618
}
621-
}
619+
};
622620

623621
added
624622
}
625623

626-
/// Adds all transactions in the iterator to the pool, returning a list of results.
627-
///
628-
/// Note: A large batch may lock the pool for a long time that blocks important operations
629-
/// like updating the pool on canonical state changes. The caller should consider having
630-
/// a max batch size to balance transaction insertions with other updates.
631-
pub fn add_transactions(
632-
&self,
633-
origin: TransactionOrigin,
634-
transactions: impl IntoIterator<Item = TransactionValidationOutcome<T::Transaction>>,
635-
) -> Vec<PoolResult<AddedTransactionOutcome>> {
636-
self.add_transactions_with_origins(transactions.into_iter().map(|tx| (origin, tx)))
637-
}
638-
639624
/// Notify all listeners about a new pending transaction.
640625
///
641626
/// See also [`Self::add_pending_listener`]

crates/transaction-pool/src/traits.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,6 @@ pub trait TransactionPool: Clone + Debug + Send + Sync {
177177
transactions: Vec<Self::Transaction>,
178178
) -> impl Future<Output = Vec<PoolResult<AddedTransactionOutcome>>> + Send;
179179

180-
/// Adds multiple _unvalidated_ transactions with individual origins.
181-
///
182-
/// Each transaction can have its own [`TransactionOrigin`].
183-
///
184-
/// Consumer: RPC
185-
fn add_transactions_with_origins(
186-
&self,
187-
transactions: Vec<(TransactionOrigin, Self::Transaction)>,
188-
) -> impl Future<Output = Vec<PoolResult<AddedTransactionOutcome>>> + Send;
189-
190180
/// Submit a consensus transaction directly to the pool
191181
fn add_consensus_transaction(
192182
&self,

0 commit comments

Comments
 (0)