mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 17:41:08 +00:00
Pruned and resubmitted metrics in transaction pool (#6322)
* pruned and resubmitted metrics * update counter once
This commit is contained in:
@@ -551,6 +551,7 @@ impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
|
||||
let revalidation_strategy = self.revalidation_strategy.clone();
|
||||
let revalidation_queue = self.revalidation_queue.clone();
|
||||
let ready_poll = self.ready_poll.clone();
|
||||
let metrics = self.metrics.clone();
|
||||
|
||||
async move {
|
||||
// We keep track of everything we prune so that later we won't add
|
||||
@@ -581,6 +582,10 @@ impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
|
||||
pruned_log.extend(prune_known_txs_for_block(id.clone(), &*api, &*pool).await);
|
||||
}
|
||||
|
||||
metrics.report(
|
||||
|metrics| metrics.block_transactions_pruned.inc_by(pruned_log.len() as u64)
|
||||
);
|
||||
|
||||
if let (true, Some(tree_route)) = (next_action.resubmit, tree_route) {
|
||||
let mut resubmit_transactions = Vec::new();
|
||||
|
||||
@@ -600,10 +605,16 @@ impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
|
||||
.into_iter()
|
||||
.filter(|tx| tx.is_signed().unwrap_or(true));
|
||||
|
||||
let mut resubmitted_to_report = 0;
|
||||
|
||||
resubmit_transactions.extend(
|
||||
block_transactions.into_iter().filter(|tx| {
|
||||
let tx_hash = pool.hash_of(&tx);
|
||||
let contains = pruned_log.contains(&tx_hash);
|
||||
|
||||
// need to count all transactions, not just filtered, here
|
||||
resubmitted_to_report += 1;
|
||||
|
||||
if !contains {
|
||||
log::debug!(
|
||||
target: "txpool",
|
||||
@@ -615,6 +626,10 @@ impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
|
||||
!contains
|
||||
})
|
||||
);
|
||||
|
||||
metrics.report(
|
||||
|metrics| metrics.block_transactions_resubmitted.inc_by(resubmitted_to_report)
|
||||
);
|
||||
}
|
||||
|
||||
if let Err(e) = pool.submit_at(
|
||||
|
||||
@@ -48,6 +48,8 @@ pub struct Metrics {
|
||||
pub validations_scheduled: Counter<U64>,
|
||||
pub validations_finished: Counter<U64>,
|
||||
pub validations_invalid: Counter<U64>,
|
||||
pub block_transactions_pruned: Counter<U64>,
|
||||
pub block_transactions_resubmitted: Counter<U64>,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
@@ -74,6 +76,20 @@ impl Metrics {
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
block_transactions_pruned: register(
|
||||
Counter::new(
|
||||
"sub_txpool_block_transactions_pruned",
|
||||
"Total number of transactions that was requested to be pruned by block events",
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
block_transactions_resubmitted: register(
|
||||
Counter::new(
|
||||
"sub_txpool_block_transactions_resubmitted",
|
||||
"Total number of transactions that was requested to be resubmitted by block events",
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user