txpool: LOG_TARGET const added (#13180)

* txpool: LOG_TARGET const added

part of: #12873

* LOG_TARGET added to tests mod

* txpool::api for api

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* ".git/.scripts/commands/fmt/fmt.sh"

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: command-bot <>
This commit is contained in:
Michal Kucharczyk
2023-01-19 23:21:41 +01:00
committed by GitHub
parent cce6d406bf
commit 57b1de3f47
11 changed files with 135 additions and 81 deletions
@@ -18,6 +18,7 @@
//! Substrate transaction pool implementation.
use crate::LOG_TARGET;
use num_traits::CheckedSub;
use sc_transaction_pool_api::ChainEvent;
use sp_blockchain::TreeRoute;
@@ -113,14 +114,14 @@ where
};
if skip_maintenance {
log::debug!(target: "txpool", "skip maintain: tree_route would be too long");
log::debug!(target: LOG_TARGET, "skip maintain: tree_route would be too long");
self.force_update(event);
return Ok(EnactmentAction::Skip)
}
// block was already finalized
if self.recent_finalized_block == new_hash {
log::debug!(target: "txpool", "handle_enactment: block already finalized");
log::debug!(target: LOG_TARGET, "handle_enactment: block already finalized");
return Ok(EnactmentAction::Skip)
}
@@ -129,9 +130,13 @@ where
let tree_route = tree_route(self.recent_best_block, new_hash)?;
log::debug!(
target: "txpool",
target: LOG_TARGET,
"resolve hash:{:?} finalized:{:?} tree_route:{:?} best_block:{:?} finalized_block:{:?}",
new_hash, finalized, tree_route, self.recent_best_block, self.recent_finalized_block
new_hash,
finalized,
tree_route,
self.recent_best_block,
self.recent_finalized_block
);
// check if recently finalized block is on retracted path. this could be
@@ -139,9 +144,10 @@ where
// best event for some old stale best head.
if tree_route.retracted().iter().any(|x| x.hash == self.recent_finalized_block) {
log::debug!(
target: "txpool",
target: LOG_TARGET,
"Recently finalized block {} would be retracted by ChainEvent {}, skipping",
self.recent_finalized_block, new_hash
self.recent_finalized_block,
new_hash
);
return Ok(EnactmentAction::Skip)
}
@@ -155,7 +161,7 @@ where
// remains valid.
if tree_route.enacted().is_empty() {
log::trace!(
target: "txpool",
target: LOG_TARGET,
"handle_enactment: no newly enacted blocks since recent best block"
);
return Ok(EnactmentAction::HandleFinalization)
@@ -176,7 +182,12 @@ where
ChainEvent::NewBestBlock { hash, .. } => self.recent_best_block = *hash,
ChainEvent::Finalized { hash, .. } => self.recent_finalized_block = *hash,
};
log::debug!(target: "txpool", "forced update: {:?}, {:?}", self.recent_best_block, self.recent_finalized_block);
log::debug!(
target: LOG_TARGET,
"forced update: {:?}, {:?}",
self.recent_best_block,
self.recent_finalized_block,
);
}
}