mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-08 12:21:09 +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()
|
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?
|
/// Is the pool empty?
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.entries.is_empty()
|
self.entries.is_empty()
|
||||||
|
|
|
@ -85,8 +85,12 @@ pub struct ChainStats {
|
||||||
pub struct TxStats {
|
pub struct TxStats {
|
||||||
/// Number of transactions in the transaction pool
|
/// Number of transactions in the transaction pool
|
||||||
pub tx_pool_size: usize,
|
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
|
/// Number of transactions in the stem pool
|
||||||
pub stem_pool_size: usize,
|
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
|
/// Struct to return relevant information about stratum workers
|
||||||
#[derive(Clone, Serialize, Debug)]
|
#[derive(Clone, Serialize, Debug)]
|
||||||
|
|
|
@ -480,19 +480,24 @@ impl Server {
|
||||||
.map(|p| PeerStats::from_peer(&p))
|
.map(|p| PeerStats::from_peer(&p))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let (tx_pool_size, stem_pool_size) = {
|
let tx_stats = {
|
||||||
let tx_pool_lock = self.tx_pool.try_read();
|
let pool = self.tx_pool.try_read();
|
||||||
match tx_pool_lock {
|
match pool {
|
||||||
Some(l) => (l.txpool.entries.len(), l.stempool.entries.len()),
|
Some(pool) => TxStats {
|
||||||
None => (0, 0),
|
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 = self.chain.head_header()?;
|
||||||
let head_stats = ChainStats {
|
let head_stats = ChainStats {
|
||||||
latest_timestamp: head.timestamp,
|
latest_timestamp: head.timestamp,
|
||||||
|
|
|
@ -109,12 +109,18 @@ impl TUIStatusListener for TUIStatusView {
|
||||||
.child(
|
.child(
|
||||||
LinearLayout::new(Orientation::Horizontal)
|
LinearLayout::new(Orientation::Horizontal)
|
||||||
.child(TextView::new("Transaction Pool Size: "))
|
.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(
|
.child(
|
||||||
LinearLayout::new(Orientation::Horizontal)
|
LinearLayout::new(Orientation::Horizontal)
|
||||||
.child(TextView::new("Stem Pool Size: "))
|
.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(
|
.child(
|
||||||
LinearLayout::new(Orientation::Horizontal).child(TextView::new(
|
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| {
|
c.call_on_id("stem_pool_size", |t: &mut TextView| {
|
||||||
t.set_content(stats.tx_stats.stem_pool_size.to_string());
|
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| {
|
/*c.call_on_id("basic_mining_config_status", |t: &mut TextView| {
|
||||||
t.set_content(basic_mining_config_status);
|
t.set_content(basic_mining_config_status);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue