mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
Additional logging for the transaction pool. (#4068)
* Additional logging for the pool. * Long line.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
4e54dfac14
commit
b5469c6e0c
@@ -17,12 +17,13 @@
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt,
|
||||
hash,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use crate::watcher;
|
||||
use sr_primitives::traits;
|
||||
use log::warn;
|
||||
use log::{debug, trace, warn};
|
||||
|
||||
/// Extrinsic pool default listener.
|
||||
pub struct Listener<H: hash::Hash + Eq, H2> {
|
||||
@@ -37,7 +38,7 @@ impl<H: hash::Hash + Eq, H2> Default for Listener<H, H2> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> {
|
||||
impl<H: hash::Hash + traits::Member + Serialize, H2: Clone + fmt::Debug> Listener<H, H2> {
|
||||
fn fire<F>(&mut self, hash: &H, fun: F) where F: FnOnce(&mut watcher::Sender<H, H2>) {
|
||||
let clean = if let Some(h) = self.watchers.get_mut(hash) {
|
||||
fun(h);
|
||||
@@ -61,11 +62,13 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> {
|
||||
|
||||
/// Notify the listeners about extrinsic broadcast.
|
||||
pub fn broadcasted(&mut self, hash: &H, peers: Vec<String>) {
|
||||
trace!(target: "txpool", "[{:?}] Broadcasted", hash);
|
||||
self.fire(hash, |watcher| watcher.broadcast(peers));
|
||||
}
|
||||
|
||||
/// New transaction was added to the ready pool or promoted from the future pool.
|
||||
pub fn ready(&mut self, tx: &H, old: Option<&H>) {
|
||||
trace!(target: "txpool", "[{:?}] Ready (replaced: {:?})", tx, old);
|
||||
self.fire(tx, |watcher| watcher.ready());
|
||||
if let Some(old) = old {
|
||||
self.fire(old, |watcher| watcher.usurped(tx.clone()));
|
||||
@@ -74,11 +77,13 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> {
|
||||
|
||||
/// New transaction was added to the future pool.
|
||||
pub fn future(&mut self, tx: &H) {
|
||||
trace!(target: "txpool", "[{:?}] Future", tx);
|
||||
self.fire(tx, |watcher| watcher.future());
|
||||
}
|
||||
|
||||
/// Transaction was dropped from the pool because of the limit.
|
||||
pub fn dropped(&mut self, tx: &H, by: Option<&H>) {
|
||||
trace!(target: "txpool", "[{:?}] Dropped (replaced by {:?})", tx, by);
|
||||
self.fire(tx, |watcher| match by {
|
||||
Some(t) => watcher.usurped(t.clone()),
|
||||
None => watcher.dropped(),
|
||||
@@ -93,6 +98,7 @@ impl<H: hash::Hash + traits::Member + Serialize, H2: Clone> Listener<H, H2> {
|
||||
|
||||
/// Transaction was pruned from the pool.
|
||||
pub fn pruned(&mut self, header_hash: H2, tx: &H) {
|
||||
debug!(target: "txpool", "[{:?}] Pruned at {:?}", tx, header_hash);
|
||||
self.fire(tx, |watcher| watcher.finalized(header_hash))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +177,12 @@ impl<B: ChainApi> Pool<B> {
|
||||
parent: &BlockId<B::Block>,
|
||||
extrinsics: &[ExtrinsicFor<B>],
|
||||
) -> impl Future<Output=Result<(), B::Error>> {
|
||||
log::debug!(
|
||||
target: "txpool",
|
||||
"Starting pruning of block {:?} (extrinsics: {})",
|
||||
at,
|
||||
extrinsics.len()
|
||||
);
|
||||
// Get details of all extrinsics that are already in the pool
|
||||
let (in_pool_hashes, in_pool_tags) = self.validated_pool.extrinsics_tags(extrinsics);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
use std::{
|
||||
collections::{HashSet, HashMap},
|
||||
fmt,
|
||||
hash,
|
||||
time,
|
||||
};
|
||||
@@ -355,7 +356,7 @@ fn fire_events<H, H2, Ex>(
|
||||
imported: &base::Imported<H, Ex>,
|
||||
) where
|
||||
H: hash::Hash + Eq + traits::Member + Serialize,
|
||||
H2: Clone,
|
||||
H2: Clone + fmt::Debug,
|
||||
{
|
||||
match *imported {
|
||||
base::Imported::Ready { ref promoted, ref failed, ref removed, ref hash } => {
|
||||
|
||||
Reference in New Issue
Block a user