fix(gui,vnish): hashrate 0-vs-dash, paused health colours, VNish per-hashboard faults
- Hashrate cell: a readable 0 hashrate now shows "0.00T" instead of a dash. The
dash is reserved for an unreadable/absent hashrate. New MinerRow.hashrate_known
records whether the miner reported a value; combined_si/num_value key off it,
and scan/fixtures set it from data.hashrate.is_some().
- Paused-miner Health icons: the control board (brain) and PSU keep their true
health (green when fine) instead of turning blue; fans turn blue only when
actually stopped (0 RPM) and stay green while spinning; hashboards stay blue
while paused (idle is the expected state).
- VNish per-hashboard faults: DataField::Messages now also reads the summary
chains (chip_statuses red/orange + per-chain state) and emits one message per
faulted board, attributed to MinerComponent::HashBoard{idx}, so the Health
column reds the specific board and its tooltip carries the fault instead of it
landing on the brain. Applied to v1_2_0 and v1_3_0. patch 0032.
Verified live: VNish 10.7.1.25 -> "Hashboard 2: 1 degraded chip(s)" on board idx
1; healthy 10.7.1.122 -> no messages. 93 unit tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
This commit is contained in:
@@ -128,6 +128,10 @@ impl Board {
|
||||
cpu,
|
||||
board_code,
|
||||
hashrate_ths: self.hashrate,
|
||||
// A miner that is mining or paused reported a current hashrate (a paused
|
||||
// one reports 0 -> "0.00T"); the blank stock demo miner reports none, so
|
||||
// it keeps the "-" dash (round 19 follow-up).
|
||||
hashrate_known: self.mining || self.paused,
|
||||
expected_ths: self.expected,
|
||||
board_hashrates,
|
||||
board_voltages,
|
||||
|
||||
@@ -82,6 +82,17 @@ pub fn format_hashrate_ths(ths: f64) -> Option<String> {
|
||||
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
||||
}
|
||||
|
||||
/// The current-hashrate reading for the combined Hashrate cell, distinguishing a
|
||||
/// reported zero from an unreadable one: `Some("0.00T")` when the firmware reported
|
||||
/// a hashrate that rounds to zero, `Some("<n>T")` for a positive reading, and
|
||||
/// `None` (renders as the "-" dash) only when the hashrate is unreadable/absent.
|
||||
pub fn format_hashrate_actual(ths: f64, known: bool) -> Option<String> {
|
||||
if !known {
|
||||
return None;
|
||||
}
|
||||
Some(format_hashrate_ths(ths).unwrap_or_else(|| "0.00T".to_string()))
|
||||
}
|
||||
|
||||
/// A hashrate number (no unit) for a given mining algorithm (round 18 #7). asic-rs
|
||||
/// stores every hashrate normalised to "TH/s", but for Equihash the underlying
|
||||
/// count is Sol/s that it reinterprets through the base H unit, so `ths * 1e12`
|
||||
@@ -140,8 +151,8 @@ fn join_board(vals: &[f64], f: impl Fn(f64) -> String) -> String {
|
||||
/// slash, prefix-only unit): blank when neither is known, the bare actual when
|
||||
/// only it is known, "-/<expected>" when only the expected is known, and
|
||||
/// "<actual>/<expected>" when both are (e.g. "80.5T/95.0T").
|
||||
fn combined_si(actual_ths: f64, expected_ths: f64) -> String {
|
||||
match (format_hashrate_ths(actual_ths), format_hashrate_ths(expected_ths)) {
|
||||
fn combined_si(actual_ths: f64, actual_known: bool, expected_ths: f64) -> String {
|
||||
match (format_hashrate_actual(actual_ths, actual_known), format_hashrate_ths(expected_ths)) {
|
||||
(None, None) => String::new(),
|
||||
(Some(a), None) => a,
|
||||
(None, Some(e)) => format!("-/{e}"),
|
||||
@@ -496,6 +507,10 @@ pub struct MinerRow {
|
||||
pub faults: Vec<Fault>,
|
||||
// performance
|
||||
pub hashrate_ths: f64,
|
||||
/// Whether the firmware actually reported a current hashrate. A reported 0
|
||||
/// renders as "0.00T"; only an unreadable/absent reading (this is false) shows
|
||||
/// the "-" dash. `hashrate_ths` alone can't distinguish the two (both are 0.0).
|
||||
pub hashrate_known: bool,
|
||||
/// Rolling average hashrate windows in TH/s (round 19 #10, T2): 1m/5m/15m/24h.
|
||||
/// 0.0 means the firmware does not report that window.
|
||||
pub hashrate_1m_ths: f64,
|
||||
@@ -1489,7 +1504,10 @@ impl Column {
|
||||
// renders "- / <expected>" (non-empty) in that case, so the generic
|
||||
// blank check below is not enough on its own.
|
||||
match self {
|
||||
Column::Hashrate if r.hashrate_ths <= 0.0 => return None,
|
||||
// An unreadable hashrate has no numeric value; a reported 0 does (0.0),
|
||||
// so a filter like "hashrate > 0" excludes a stopped miner but "<= 50"
|
||||
// still matches it.
|
||||
Column::Hashrate if !r.hashrate_known => return None,
|
||||
Column::TotalChips if r.total_chips.is_none() => return None,
|
||||
_ => {}
|
||||
}
|
||||
@@ -1596,7 +1614,7 @@ impl Column {
|
||||
let pool_worker = |i: usize| r.pools.get(i).map(|(_, w)| w.clone()).unwrap_or_default();
|
||||
match self {
|
||||
Column::Ip => r.ip.clone(),
|
||||
Column::Hashrate => combined_si(r.hashrate_ths, r.expected_ths),
|
||||
Column::Hashrate => combined_si(r.hashrate_ths, r.hashrate_known, r.expected_ths),
|
||||
// Rolling average windows: a single TH/s value, blank when not reported
|
||||
// (round 19 #10, T2).
|
||||
Column::Hashrate1m => format_hashrate_ths(r.hashrate_1m_ths).unwrap_or_default(),
|
||||
@@ -2826,7 +2844,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn numeric_filter_operators() {
|
||||
let r = MinerRow { hashrate_ths: 100.0, is_mining: true, ..Default::default() };
|
||||
let r = MinerRow { hashrate_ths: 100.0, hashrate_known: true, is_mining: true, ..Default::default() };
|
||||
let c = Column::Hashrate;
|
||||
let n = |op, a: f64, b: f64| ColFilter::Num { op, a, b }.matches(c, &r);
|
||||
assert!(n(NumOp::Gt, 50.0, 0.0));
|
||||
@@ -2847,7 +2865,7 @@ mod tests {
|
||||
assert_eq!(Column::Firmware.num_value(&r), None, "text column");
|
||||
assert_eq!(Column::Ip.num_value(&r), None, "IP is text, not numeric");
|
||||
assert_eq!(Column::Efficiency.num_value(&r), None, "blank numeric -> None");
|
||||
let r2 = MinerRow { hashrate_ths: 42.0, ..Default::default() };
|
||||
let r2 = MinerRow { hashrate_ths: 42.0, hashrate_known: true, ..Default::default() };
|
||||
assert_eq!(Column::Hashrate.num_value(&r2), Some(42.0));
|
||||
}
|
||||
|
||||
@@ -2920,6 +2938,7 @@ mod tests {
|
||||
|
||||
let actual_only = MinerRow {
|
||||
hashrate_ths: 60.0,
|
||||
hashrate_known: true,
|
||||
total_chips: Some(210),
|
||||
..Default::default()
|
||||
};
|
||||
@@ -2931,11 +2950,24 @@ mod tests {
|
||||
expected_chips: Some(228),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(Column::Hashrate.cell(&expected_only), "-/200T", "only expected -> '-/<expected>'");
|
||||
assert_eq!(Column::Hashrate.cell(&expected_only), "-/200T", "only expected (actual unreadable) -> '-/<expected>'");
|
||||
assert_eq!(Column::TotalChips.cell(&expected_only), "- / 228");
|
||||
|
||||
// A reported zero is a real reading -> "0.00T", never the dash. The dash
|
||||
// (expected_only above) is reserved for an unreadable actual.
|
||||
let reported_zero = MinerRow {
|
||||
hashrate_ths: 0.0,
|
||||
hashrate_known: true,
|
||||
expected_ths: 200.0,
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(Column::Hashrate.cell(&reported_zero), "0.00T/200T", "reported 0 -> 0.00T, not a dash");
|
||||
let reported_zero_no_expected = MinerRow { hashrate_ths: 0.0, hashrate_known: true, ..Default::default() };
|
||||
assert_eq!(Column::Hashrate.cell(&reported_zero_no_expected), "0.00T");
|
||||
|
||||
let both = MinerRow {
|
||||
hashrate_ths: 60.0,
|
||||
hashrate_known: true,
|
||||
expected_ths: 200.0,
|
||||
total_chips: Some(190),
|
||||
expected_chips: Some(228),
|
||||
@@ -2959,6 +2991,7 @@ mod tests {
|
||||
|
||||
let both = MinerRow {
|
||||
hashrate_ths: 60.0,
|
||||
hashrate_known: true,
|
||||
expected_ths: 200.0,
|
||||
total_chips: Some(190),
|
||||
expected_chips: Some(228),
|
||||
|
||||
@@ -747,6 +747,9 @@ fn partial_row(miner: &dyn Miner, ip: std::net::IpAddr) -> MinerRow {
|
||||
|
||||
async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
let data = miner.get_data().await;
|
||||
// Whether the firmware reported a current hashrate at all: a reported 0 renders
|
||||
// "0.00T", an absent one the "-" dash (round 19 follow-up).
|
||||
let hashrate_known = data.hashrate.is_some();
|
||||
let hashrate_ths = data
|
||||
.hashrate
|
||||
.as_ref()
|
||||
@@ -1111,6 +1114,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
cpu,
|
||||
board_code,
|
||||
hashrate_ths,
|
||||
hashrate_known,
|
||||
hashrate_1m_ths,
|
||||
hashrate_5m_ths,
|
||||
hashrate_15m_ths,
|
||||
|
||||
+27
-14
@@ -438,33 +438,44 @@ fn encode_component_health(
|
||||
max_fans: usize,
|
||||
max_boards: usize,
|
||||
) -> String {
|
||||
use crate::model::CompHealth;
|
||||
let mut segs: Vec<Segment> = Vec::new();
|
||||
// A paused/stopped miner is intentionally halted, not broken: every component
|
||||
// it reports as idle (power off, fans spun down, boards not hashing) is
|
||||
// expected, not a fault, so colour each one blue instead of its red/amber
|
||||
// health colour -- otherwise a paused miner reads as broken (round 19 #19,
|
||||
// extended: originally boards only, but idle fans/power still showed red).
|
||||
// A genuinely undetected component (Unreachable) stays grey: even when paused,
|
||||
// "not present" is not "paused".
|
||||
let col = |h: crate::model::CompHealth| {
|
||||
if r.paused && h != crate::model::CompHealth::Unreachable {
|
||||
// On a paused/stopped miner, a component that is off *because* the miner is
|
||||
// halted is expected, not a fault, so it reads blue (paused) instead of red.
|
||||
// But this only applies where "not working" is a consequence of the pause:
|
||||
// - Hashboards: idle (not hashing) is exactly what pausing does -> blue when
|
||||
// paused (any detected board; an undetected one stays grey). Round 19 #19.
|
||||
// - Fans: blue ONLY when actually stopped (0 RPM -> Down); a fan still
|
||||
// spinning stays green/amber -- pausing doesn't necessarily stop the fans.
|
||||
// - Control board + PSU: still running / powered, so they keep their true
|
||||
// health (green when fine) even while paused -- never forced blue.
|
||||
let paused = r.paused;
|
||||
let board_col = |h: CompHealth| {
|
||||
if paused && h != CompHealth::Unreachable {
|
||||
pal.accent
|
||||
} else {
|
||||
health_color(pal, h)
|
||||
}
|
||||
};
|
||||
segs.push((Some(col(r.power_health())), SHAPE_BOLT.to_string()));
|
||||
segs.push((Some(col(r.control_health())), SHAPE_BRAIN.to_string()));
|
||||
let fan_col = |h: CompHealth| {
|
||||
if paused && h == CompHealth::Down {
|
||||
pal.accent
|
||||
} else {
|
||||
health_color(pal, h)
|
||||
}
|
||||
};
|
||||
segs.push((Some(health_color(pal, r.power_health())), SHAPE_BOLT.to_string()));
|
||||
segs.push((Some(health_color(pal, r.control_health())), SHAPE_BRAIN.to_string()));
|
||||
let fans = r.fan_healths();
|
||||
for h in &fans {
|
||||
segs.push((Some(col(*h)), SHAPE_FAN.to_string()));
|
||||
segs.push((Some(fan_col(*h)), SHAPE_FAN.to_string()));
|
||||
}
|
||||
for _ in fans.len()..max_fans {
|
||||
segs.push((None, SHAPE_GAP.to_string()));
|
||||
}
|
||||
let boards = r.board_healths();
|
||||
for h in &boards {
|
||||
segs.push((Some(col(*h)), SHAPE_CHIP.to_string()));
|
||||
segs.push((Some(board_col(*h)), SHAPE_CHIP.to_string()));
|
||||
}
|
||||
for _ in boards.len()..max_boards {
|
||||
segs.push((None, SHAPE_GAP.to_string()));
|
||||
@@ -1274,7 +1285,9 @@ impl App {
|
||||
// on the ACTUAL being known, so an unknown actual renders as
|
||||
// "-/<expected>" in the default colour rather than a red 0%.
|
||||
Column::Hashrate => {
|
||||
let actual = format_hashrate_ths(r.hashrate_ths);
|
||||
// A reported 0 shows "0.00T" (not a dash); the dash is only for
|
||||
// an unreadable reading (hashrate_known == false).
|
||||
let actual = format_hashrate_actual(r.hashrate_ths, r.hashrate_known);
|
||||
let expected = format_hashrate_ths(r.expected_ths);
|
||||
let ratio = (r.hashrate_ths > 0.0)
|
||||
.then(|| actual_expected_ratio(r.hashrate_ths, r.expected_ths))
|
||||
|
||||
Reference in New Issue
Block a user