Fix quadratic iterations over transaction pool (#4736)

* transaction pool changes

* service & network changes

* address review

* reduce future pool
This commit is contained in:
Nikolay Volf
2020-01-27 09:26:42 -08:00
committed by Gavin Wood
parent 76acc96f3a
commit ed3da9f903
12 changed files with 102 additions and 37 deletions
+2 -2
View File
@@ -906,9 +906,9 @@ ServiceBuilder<
let network = Arc::downgrade(&network);
let transaction_pool_ = transaction_pool.clone();
let events = transaction_pool.import_notification_stream()
.for_each(move |_| {
.for_each(move |hash| {
if let Some(network) = network.upgrade() {
network.trigger_repropagate();
network.propagate_extrinsic(hash);
}
let status = transaction_pool_.status();
telemetry!(SUBSTRATE_INFO; "txpool.import";
+5 -1
View File
@@ -608,7 +608,7 @@ where
H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize,
E: 'static + IntoPoolError + From<sp_transaction_pool::error::Error>,
{
fn transactions(&self) -> Vec<(H, <B as BlockT>::Extrinsic)> {
fn transactions(&self) -> Vec<(H, B::Extrinsic)> {
transactions_to_propagate(&*self.pool)
}
@@ -660,6 +660,10 @@ where
fn on_broadcasted(&self, propagations: HashMap<H, Vec<String>>) {
self.pool.on_broadcasted(propagations)
}
fn transaction(&self, hash: &H) -> Option<B::Extrinsic> {
self.pool.ready_transaction(hash).map(|tx| tx.data().clone())
}
}
#[cfg(test)]