Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf committed Jan 21, 2020
1 parent cada84b commit 93834a3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions client/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<Vec<_>>();

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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit 93834a3

Please sign in to comment.