Add network hashrate info to Mining pane in TUI (#1353)
Found it's useful, we even have a section in user docs for that https://github.com/mimblewimble/docs/wiki/Testnet3-FAQ
This commit is contained in:
committed by
Ignotus Peverell
parent
6b74cf5098
commit
a2fac26282
@@ -146,6 +146,13 @@ pub struct PeerStats {
|
||||
pub direction: String,
|
||||
}
|
||||
|
||||
impl StratumStats {
|
||||
/// Calculate network hashrate
|
||||
pub fn network_hashrate(&self) -> f64 {
|
||||
42.0 * (self.network_difficulty as f64 / (self.cuckoo_size - 1) as f64) / 60.0
|
||||
}
|
||||
}
|
||||
|
||||
impl PeerStats {
|
||||
/// Convert from a peer directly
|
||||
pub fn from_peer(peer: &p2p::Peer) -> PeerStats {
|
||||
|
||||
@@ -211,6 +211,10 @@ impl TUIStatusListener for TUIMiningView {
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_network_difficulty_status")),
|
||||
)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_network_hashrate")),
|
||||
)
|
||||
.child(
|
||||
LinearLayout::new(Orientation::Horizontal)
|
||||
.child(TextView::new(" ").with_id("stratum_cuckoo_size_status")),
|
||||
@@ -304,6 +308,11 @@ impl TUIStatusListener for TUIMiningView {
|
||||
},
|
||||
);
|
||||
let stratum_stats = stats.stratum_stats.clone();
|
||||
let stratum_network_hashrate = format!(
|
||||
"Network Hashrate: {:.*}",
|
||||
2,
|
||||
stratum_stats.network_hashrate()
|
||||
);
|
||||
let worker_stats = stratum_stats.worker_stats;
|
||||
let stratum_enabled = format!("Mining server enabled: {}", stratum_stats.is_enabled);
|
||||
let stratum_is_running = format!("Mining server running: {}", stratum_stats.is_running);
|
||||
@@ -328,6 +337,9 @@ impl TUIStatusListener for TUIMiningView {
|
||||
c.call_on_id("stratum_network_difficulty_status", |t: &mut TextView| {
|
||||
t.set_content(stratum_network_difficulty);
|
||||
});
|
||||
c.call_on_id("stratum_network_hashrate", |t: &mut TextView| {
|
||||
t.set_content(stratum_network_hashrate);
|
||||
});
|
||||
c.call_on_id("stratum_cuckoo_size_status", |t: &mut TextView| {
|
||||
t.set_content(stratum_cuckoo_size);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user