From 3ad0a1b7c08e63a2581595cb2cd55f11ccd60f4f Mon Sep 17 00:00:00 2001
From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
Date: Fri, 16 Aug 2024 16:27:15 +0200
Subject: [PATCH] fatp: submit_one uses submit_at -- cd.

---
 .../src/fork_aware_txpool/tx_mem_pool.rs      | 24 ++++---------------
 .../src/fork_aware_txpool/view_store.rs       | 19 ---------------
 2 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs b/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs
index 839a88ce59d..b2fce5a0075 100644
--- a/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs
+++ b/substrate/client/transaction-pool/src/fork_aware_txpool/tx_mem_pool.rs
@@ -186,22 +186,6 @@ where
 		}
 	}
 
-	pub(super) fn push_unwatched(
-		&self,
-		source: TransactionSource,
-		xt: ExtrinsicFor<ChainApi>,
-	) -> Result<(), ChainApi::Error> {
-		let mut transactions = self.transactions.write();
-		let hash = self.api.hash_and_length(&xt).0;
-		self.try_insert(
-			transactions.len(),
-			transactions.entry(hash),
-			hash,
-			TxInMemPool::new_unwatched(source, xt),
-		)
-		.map(|_| ())
-	}
-
 	/// Adds new unwatched transactions to the internal buffer not exceeding the limit.
 	///
 	/// Returns the vector of results for each transaction, the order corresponds to the input
@@ -443,9 +427,9 @@ mod tx_mem_pool_tests {
 			sc_transaction_pool_api::error::Error::ImmediatelyDropped
 		));
 		let xt = Arc::from(uxt(99));
-		let result = mempool.push_unwatched(TransactionSource::External, xt);
+		let mut result = mempool.extend_unwatched(TransactionSource::External, vec![xt]);
 		assert!(matches!(
-			result.unwrap_err(),
+			result.pop().unwrap().unwrap_err(),
 			sc_transaction_pool_api::error::Error::ImmediatelyDropped
 		));
 	}
@@ -468,9 +452,9 @@ mod tx_mem_pool_tests {
 			result.unwrap_err(),
 			sc_transaction_pool_api::error::Error::AlreadyImported(_)
 		));
-		let result = mempool.push_unwatched(TransactionSource::External, xt1);
+		let mut result = mempool.extend_unwatched(TransactionSource::External, vec![xt1]);
 		assert!(matches!(
-			result.unwrap_err(),
+			result.pop().unwrap().unwrap_err(),
 			sc_transaction_pool_api::error::Error::AlreadyImported(_)
 		));
 	}
diff --git a/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs b/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs
index 69de7a76c41..f5a15a49727 100644
--- a/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs
+++ b/substrate/client/transaction-pool/src/fork_aware_txpool/view_store.rs
@@ -107,25 +107,6 @@ where
 		HashMap::<_, _>::from_iter(results.into_iter())
 	}
 
-	/// Imports one unverified extrinsic to every view
-	pub(super) async fn submit_one(
-		&self,
-		source: TransactionSource,
-		xt: ExtrinsicFor<ChainApi>,
-	) -> HashMap<Block::Hash, Result<ExtrinsicHash<ChainApi>, ChainApi::Error>> {
-		let mut output = HashMap::new();
-		let mut result = self.submit_at(source, std::iter::once(xt)).await;
-		result.iter_mut().for_each(|(hash, result)| {
-			output.insert(
-				*hash,
-				result
-					.pop()
-					.expect("for one transaction there shall be exactly one result. qed"),
-			);
-		});
-		output
-	}
-
 	/// Import a single extrinsic and starts to watch its progress in the pool.
 	pub(super) async fn submit_and_watch(
 		&self,
-- 
GitLab