diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index 7f3fa4a117..eca3814d92 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -384,23 +384,6 @@ where self.pool.validator().validate_transactions_with_origin(origin, transactions).await } - /// Validates all transactions with their individual origins. - /// - /// This returns the validated transactions in the same order as input. - async fn validate_all_with_origins( - &self, - transactions: Vec<(TransactionOrigin, V::Transaction)>, - ) -> Vec<(TransactionOrigin, TransactionValidationOutcome)> { - if transactions.len() == 1 { - let (origin, tx) = transactions.into_iter().next().unwrap(); - let res = self.pool.validator().validate_transaction(origin, tx).await; - return vec![(origin, res)] - } - let origins: Vec<_> = transactions.iter().map(|(origin, _)| *origin).collect(); - let tx_outcomes = self.pool.validator().validate_transactions(transactions).await; - origins.into_iter().zip(tx_outcomes).collect() - } - /// Number of transactions in the entire pool pub fn len(&self) -> usize { self.pool.len() @@ -516,18 +499,6 @@ where self.pool.add_transactions(origin, validated.into_iter()) } - async fn add_transactions_with_origins( - &self, - transactions: Vec<(TransactionOrigin, Self::Transaction)>, - ) -> Vec> { - if transactions.is_empty() { - return Vec::new() - } - let validated = self.validate_all_with_origins(transactions).await; - - self.pool.add_transactions_with_origins(validated) - } - fn transaction_event_listener(&self, tx_hash: TxHash) -> Option { self.pool.add_transaction_event_listener(tx_hash) } diff --git a/crates/transaction-pool/src/noop.rs b/crates/transaction-pool/src/noop.rs index dc5bb9c307..a553ea6e87 100644 --- a/crates/transaction-pool/src/noop.rs +++ b/crates/transaction-pool/src/noop.rs @@ -98,19 +98,6 @@ impl TransactionPool for NoopTransactionPool { .collect() } - async fn add_transactions_with_origins( - &self, - transactions: Vec<(TransactionOrigin, Self::Transaction)>, - ) -> Vec> { - transactions - .into_iter() - .map(|(_, transaction)| { - let hash = *transaction.hash(); - Err(PoolError::other(hash, Box::new(NoopInsertError::new(transaction)))) - }) - .collect() - } - fn transaction_event_listener(&self, _tx_hash: TxHash) -> Option { None } diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 74622b7189..02fc1ac753 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -571,24 +571,22 @@ where Ok(listener) } - /// Adds all transactions in the iterator to the pool, each with its individual origin, - /// returning a list of results. + /// Adds all transactions in the iterator to the pool, returning a list of results. /// /// Note: A large batch may lock the pool for a long time that blocks important operations /// like updating the pool on canonical state changes. The caller should consider having /// a max batch size to balance transaction insertions with other updates. - pub fn add_transactions_with_origins( + pub fn add_transactions( &self, - transactions: impl IntoIterator< - Item = (TransactionOrigin, TransactionValidationOutcome), - >, + origin: TransactionOrigin, + transactions: impl IntoIterator>, ) -> Vec> { // Process all transactions in one write lock, maintaining individual origins let (mut added, discarded) = { let mut pool = self.pool.write(); let added = transactions .into_iter() - .map(|(origin, tx)| self.add_transaction(&mut pool, origin, tx)) + .map(|tx| self.add_transaction(&mut pool, origin, tx)) .collect::>(); // Enforce the pool size limits if at least one transaction was added successfully @@ -618,24 +616,11 @@ where *res = Err(PoolError::new(*hash, PoolErrorKind::DiscardedOnInsert)) } } - } + }; added } - /// Adds all transactions in the iterator to the pool, returning a list of results. - /// - /// Note: A large batch may lock the pool for a long time that blocks important operations - /// like updating the pool on canonical state changes. The caller should consider having - /// a max batch size to balance transaction insertions with other updates. - pub fn add_transactions( - &self, - origin: TransactionOrigin, - transactions: impl IntoIterator>, - ) -> Vec> { - self.add_transactions_with_origins(transactions.into_iter().map(|tx| (origin, tx))) - } - /// Notify all listeners about a new pending transaction. /// /// See also [`Self::add_pending_listener`] diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 2b9d8bae8a..e5f9de0e60 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -177,16 +177,6 @@ pub trait TransactionPool: Clone + Debug + Send + Sync { transactions: Vec, ) -> impl Future>> + Send; - /// Adds multiple _unvalidated_ transactions with individual origins. - /// - /// Each transaction can have its own [`TransactionOrigin`]. - /// - /// Consumer: RPC - fn add_transactions_with_origins( - &self, - transactions: Vec<(TransactionOrigin, Self::Transaction)>, - ) -> impl Future>> + Send; - /// Submit a consensus transaction directly to the pool fn add_consensus_transaction( &self,