Skip to content
Snippets Groups Projects
Unverified Commit 8d409eb7 authored by dharjeezy's avatar dharjeezy
Browse files

nit conversations

parent 49c2f221
Branches
No related merge requests found
Pipeline #513211 waiting for manual action with stages
in 2 minutes and 21 seconds
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
......
......@@ -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
}
}
......@@ -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);
......
......@@ -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 },
)
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment