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

Commit d25dde4

Browse files
committed
review fixes
1 parent cada84b commit d25dde4

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

client/transaction-pool/src/api.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,18 @@ impl<Client, F, Block> sc_transaction_graph::ChainApi for LightChainApi<Client,
221221
let fetcher = self.fetcher.clone();
222222
async move {
223223
let transactions = fetcher.remote_body({
224-
RemoteBodyRequest {
225-
header,
226-
retry_count: None,
227-
}
228-
}).await;
229-
230-
Ok(Some(transactions.unwrap_or(Vec::new())))
224+
RemoteBodyRequest {
225+
header,
226+
retry_count: None,
227+
}
228+
})
229+
.await
230+
.unwrap_or_else(|e| {
231+
log::warn!(target: "txpool", "Failed to fetch block body: {:?}", e);
232+
Vec::new()
233+
});
234+
235+
Ok(Some(transactions))
231236
}.boxed()
232237
}
233238
}

client/transaction-pool/src/lib.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use parking_lot::Mutex;
3434

3535
use sp_runtime::{
3636
generic::BlockId,
37-
traits::{Block as BlockT, NumberFor, SimpleArithmetic},
37+
traits::{Block as BlockT, NumberFor, SimpleArithmetic, Extrinsic},
3838
};
3939
use sp_transaction_pool::{
4040
TransactionPool, PoolStatus, ImportNotificationStream,
@@ -278,7 +278,7 @@ where
278278
let block_number = match api.block_id_to_number(&id) {
279279
Ok(Some(number)) => number,
280280
_ => {
281-
log::trace!(target: "txqueue", "Skipping chain event - no numbrer for that block {:?}", id);
281+
log::trace!(target: "txqueue", "Skipping chain event - no number for that block {:?}", id);
282282
return Box::pin(ready(()));
283283
}
284284
};
@@ -292,18 +292,21 @@ where
292292
let retracted = retracted.to_vec();
293293

294294
async move {
295-
let hashes = api.block_body(&id).await
296-
.unwrap_or_else(|e| {
297-
log::warn!("Prune known transactions: error request {:?}!", e);
298-
None
299-
})
295+
// We don't query block if we won't prune anything
296+
if !pool.status().is_empty() {
297+
let hashes = api.block_body(&id).await
298+
.unwrap_or_else(|e| {
299+
log::warn!("Prune known transactions: error request {:?}!", e);
300+
None
301+
})
300302
.unwrap_or_default()
301303
.into_iter()
302304
.map(|tx| pool.hash_of(&tx))
303305
.collect::<Vec<_>>();
304306

305-
if let Err(e) = pool.prune_known(&id, &hashes) {
306-
log::error!("Cannot prune known in the pool {:?}!", e);
307+
if let Err(e) = pool.prune_known(&id, &hashes) {
308+
log::error!("Cannot prune known in the pool {:?}!", e);
309+
}
307310
}
308311

309312
if next_action.resubmit {
@@ -315,7 +318,9 @@ where
315318
log::warn!("Failed to fetch block body {:?}!", e);
316319
None
317320
})
318-
.unwrap_or_default();
321+
.unwrap_or_default()
322+
.into_iter()
323+
.filter(|tx| tx.is_signed().unwrap_or(true));
319324

320325
resubmit_transactions.extend(block_transactions);
321326
}

0 commit comments

Comments
 (0)