mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
Fix quadratic iterations over transaction pool (#4736)
* transaction pool changes * service & network changes * address review * reduce future pool
This commit is contained in:
@@ -1135,18 +1135,26 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Call when we must propagate ready extrinsics to peers.
|
||||
pub fn propagate_extrinsics(
|
||||
/// Propagate one extrinsic.
|
||||
pub fn propagate_extrinsic(
|
||||
&mut self,
|
||||
hash: &H,
|
||||
) {
|
||||
debug!(target: "sync", "Propagating extrinsics");
|
||||
|
||||
debug!(target: "sync", "Propagating extrinsic [{:?}]", hash);
|
||||
// Accept transactions only when fully synced
|
||||
if self.sync.status().state != SyncState::Idle {
|
||||
return;
|
||||
}
|
||||
if let Some(extrinsic) = self.transaction_pool.transaction(hash) {
|
||||
let propagated_to = self.do_propagate_extrinsics(&[(hash.clone(), extrinsic)]);
|
||||
self.transaction_pool.on_broadcasted(propagated_to);
|
||||
}
|
||||
}
|
||||
|
||||
let extrinsics = self.transaction_pool.transactions();
|
||||
fn do_propagate_extrinsics(
|
||||
&mut self,
|
||||
extrinsics: &[(H, B::Extrinsic)],
|
||||
) -> HashMap<H, Vec<String>> {
|
||||
let mut propagated_to = HashMap::new();
|
||||
for (who, peer) in self.context_data.peers.iter_mut() {
|
||||
// never send extrinsics to the light node
|
||||
@@ -1177,6 +1185,18 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
}
|
||||
|
||||
propagated_to
|
||||
}
|
||||
|
||||
/// Call when we must propagate ready extrinsics to peers.
|
||||
pub fn propagate_extrinsics(&mut self) {
|
||||
debug!(target: "sync", "Propagating extrinsics");
|
||||
// Accept transactions only when fully synced
|
||||
if self.sync.status().state != SyncState::Idle {
|
||||
return;
|
||||
}
|
||||
let extrinsics = self.transaction_pool.transactions();
|
||||
let propagated_to = self.do_propagate_extrinsics(&extrinsics);
|
||||
self.transaction_pool.on_broadcasted(propagated_to);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user