mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 08:51:08 +03:00
add tx pool kernel counts to tui status page (#3111)
* add tx pool kernel counts to tui status page * fix formatting on tui
This commit is contained in:
parent
a1061f09a8
commit
8d2c43d7e8
4 changed files with 39 additions and 12 deletions
|
@ -446,6 +446,12 @@ impl Pool {
|
|||
self.entries.len()
|
||||
}
|
||||
|
||||
/// Number of transaction kernels in the pool.
|
||||
/// This may differ from the size (number of transactions) due to tx aggregation.
|
||||
pub fn kernel_count(&self) -> usize {
|
||||
self.entries.iter().map(|x| x.tx.kernels().len()).sum()
|
||||
}
|
||||
|
||||
/// Is the pool empty?
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.entries.is_empty()
|
||||
|
|
|
@ -85,8 +85,12 @@ pub struct ChainStats {
|
|||
pub struct TxStats {
|
||||
/// Number of transactions in the transaction pool
|
||||
pub tx_pool_size: usize,
|
||||
/// Number of transaction kernels in the transaction pool
|
||||
pub tx_pool_kernels: usize,
|
||||
/// Number of transactions in the stem pool
|
||||
pub stem_pool_size: usize,
|
||||
/// Number of transaction kernels in the stem pool
|
||||
pub stem_pool_kernels: usize,
|
||||
}
|
||||
/// Struct to return relevant information about stratum workers
|
||||
#[derive(Clone, Serialize, Debug)]
|
||||
|
|
|
@ -480,19 +480,24 @@ impl Server {
|
|||
.map(|p| PeerStats::from_peer(&p))
|
||||
.collect();
|
||||
|
||||
let (tx_pool_size, stem_pool_size) = {
|
||||
let tx_pool_lock = self.tx_pool.try_read();
|
||||
match tx_pool_lock {
|
||||
Some(l) => (l.txpool.entries.len(), l.stempool.entries.len()),
|
||||
None => (0, 0),
|
||||
let tx_stats = {
|
||||
let pool = self.tx_pool.try_read();
|
||||
match pool {
|
||||
Some(pool) => TxStats {
|
||||
tx_pool_size: pool.txpool.size(),
|
||||
tx_pool_kernels: pool.txpool.kernel_count(),
|
||||
stem_pool_size: pool.stempool.size(),
|
||||
stem_pool_kernels: pool.stempool.kernel_count(),
|
||||
},
|
||||
None => TxStats {
|
||||
tx_pool_size: 0,
|
||||
tx_pool_kernels: 0,
|
||||
stem_pool_size: 0,
|
||||
stem_pool_kernels: 0,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
let tx_stats = TxStats {
|
||||
tx_pool_size,
|
||||
stem_pool_size,
|
||||
};
|
||||
|
||||
let head = self.chain.head_header()?;
|
||||
let head_stats = ChainStats {
|
||||
latest_timestamp: head.timestamp,
|
||||
|
|
|
@ -109,12 +109,18 @@ impl TUIStatusListener for TUIStatusView {
|
|||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Transaction Pool Size: "))
|
||||
.child(TextView::new(" ").with_id("tx_pool_size")),
|
||||
.child(TextView::new("0").with_id("tx_pool_size"))
|
||||
.child(TextView::new(" ("))
|
||||
.child(TextView::new("0").with_id("tx_pool_kernels"))
|
||||
.child(TextView::new(")")),
|
||||
)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new("Stem Pool Size: "))
|
||||
.child(TextView::new(" ").with_id("stem_pool_size")),
|
||||
.child(TextView::new("0").with_id("stem_pool_size"))
|
||||
.child(TextView::new(" ("))
|
||||
.child(TextView::new("0").with_id("stem_pool_kernels"))
|
||||
.child(TextView::new(")")),
|
||||
)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal).child(TextView::new(
|
||||
|
@ -307,6 +313,12 @@ impl TUIStatusListener for TUIStatusView {
|
|||
c.call_on_id("stem_pool_size", |t: &mut TextView| {
|
||||
t.set_content(stats.tx_stats.stem_pool_size.to_string());
|
||||
});
|
||||
c.call_on_id("tx_pool_kernels", |t: &mut TextView| {
|
||||
t.set_content(stats.tx_stats.tx_pool_kernels.to_string());
|
||||
});
|
||||
c.call_on_id("stem_pool_kernels", |t: &mut TextView| {
|
||||
t.set_content(stats.tx_stats.stem_pool_kernels.to_string());
|
||||
});
|
||||
/*c.call_on_id("basic_mining_config_status", |t: &mut TextView| {
|
||||
t.set_content(basic_mining_config_status);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue