From 8d409eb740d75e3b91c0f3412d7fb210af99514f Mon Sep 17 00:00:00 2001 From: dharjeezy <dharjeezy@gmail.com> Date: Mon, 27 Jan 2025 11:14:51 +0100 Subject: [PATCH] nit conversations --- prdoc/pr_5978.prdoc | 2 +- substrate/client/network/transactions/src/config.rs | 4 ++-- substrate/client/network/transactions/src/lib.rs | 2 +- substrate/client/service/src/lib.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/prdoc/pr_5978.prdoc b/prdoc/pr_5978.prdoc index 14957ea5eff..9b545c20d66 100644 --- a/prdoc/pr_5978.prdoc +++ b/prdoc/pr_5978.prdoc @@ -1,7 +1,7 @@ title: `networking::TransactionPool` should accept `Arc` doc: - audience: Node Dev - description: The TransactionPool trait now accepts an `Arc` for transactions. + description: The `sc_network_transactions::config::TransactionPool` trait now accepts an `Arc` for transactions. crates: - name: sc-network-transactions bump: minor diff --git a/substrate/client/network/transactions/src/config.rs b/substrate/client/network/transactions/src/config.rs index e3b80ab7bc9..42a335d7041 100644 --- a/substrate/client/network/transactions/src/config.rs +++ b/substrate/client/network/transactions/src/config.rs @@ -67,7 +67,7 @@ pub trait TransactionPool<H: ExHashT, B: BlockT>: Send + Sync { /// Notify the pool about transactions broadcast. fn on_broadcasted(&self, propagations: HashMap<H, Vec<String>>); /// Get transaction by hash. - fn transaction(&self, hash: &H) -> Option<B::Extrinsic>; + fn transaction(&self, hash: &H) -> Option<Arc<B::Extrinsic>>; } /// Dummy implementation of the [`TransactionPool`] trait for a transaction pool that is always @@ -93,7 +93,7 @@ impl<H: ExHashT + Default, B: BlockT> TransactionPool<H, B> for EmptyTransaction fn on_broadcasted(&self, _: HashMap<H, Vec<String>>) {} - fn transaction(&self, _h: &H) -> Option<B::Extrinsic> { + fn transaction(&self, _h: &H) -> Option<Arc<B::Extrinsic>> { None } } diff --git a/substrate/client/network/transactions/src/lib.rs b/substrate/client/network/transactions/src/lib.rs index f86ece0cfb0..ae74effc148 100644 --- a/substrate/client/network/transactions/src/lib.rs +++ b/substrate/client/network/transactions/src/lib.rs @@ -472,7 +472,7 @@ where debug!(target: LOG_TARGET, "Propagating transaction [{:?}]", hash); if let Some(transaction) = self.transaction_pool.transaction(hash) { let propagated_to = - self.do_propagate_transactions(&[(hash.clone(), Arc::new(transaction))]); + self.do_propagate_transactions(&[(hash.clone(), transaction)]); self.transaction_pool.on_broadcasted(propagated_to); } else { debug!(target: "sync", "Propagating transaction failure [{:?}]", hash); diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index 62f9dbba73d..e631646a7b8 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -559,10 +559,10 @@ where self.pool.on_broadcasted(propagations) } - fn transaction(&self, hash: &H) -> Option<B::Extrinsic> { + fn transaction(&self, hash: &H) -> Option<Arc<B::Extrinsic>> { self.pool.ready_transaction(hash).and_then( // Only propagable transactions should be resolved for network service. - |tx| if tx.is_propagable() { Some((**tx.data()).clone()) } else { None }, + |tx| if tx.is_propagable() { Some(Arc::new((**tx.data()).clone())) } else { None }, ) } } -- GitLab