From 93834a32c4c5573a0777a00ca1dc9a6badd3b2d4 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Tue, 21 Jan 2020 14:12:50 +0300 Subject: [PATCH] review fixes --- client/transaction-pool/src/lib.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 925c71d52e3a4..edb58984d16db 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -34,7 +34,7 @@ use parking_lot::Mutex; use sp_runtime::{ generic::BlockId, - traits::{Block as BlockT, NumberFor, SimpleArithmetic}, + traits::{Block as BlockT, NumberFor, SimpleArithmetic, Extrinsic}, }; use sp_transaction_pool::{ TransactionPool, PoolStatus, ImportNotificationStream, @@ -292,18 +292,21 @@ where let retracted = retracted.to_vec(); async move { - let hashes = api.block_body(&id).await - .unwrap_or_else(|e| { - log::warn!("Prune known transactions: error request {:?}!", e); - None - }) + // We don't query block if we won't prune anything + if !pool.status().is_empty() { + let hashes = api.block_body(&id).await + .unwrap_or_else(|e| { + log::warn!("Prune known transactions: error request {:?}!", e); + None + }) .unwrap_or_default() .into_iter() .map(|tx| pool.hash_of(&tx)) .collect::>(); - if let Err(e) = pool.prune_known(&id, &hashes) { - log::error!("Cannot prune known in the pool {:?}!", e); + if let Err(e) = pool.prune_known(&id, &hashes) { + log::error!("Cannot prune known in the pool {:?}!", e); + } } if next_action.resubmit { @@ -315,7 +318,9 @@ where log::warn!("Failed to fetch block body {:?}!", e); None }) - .unwrap_or_default(); + .unwrap_or_default() + .into_iter() + .filter(|tx| tx.is_signed().unwrap_or(true)); resubmit_transactions.extend(block_transactions); }