asic-rs telemetry T2a: rolling average hashrate windows (1m/5m/15m/24h)

Round 19 #10 telemetry extension, tier 2. Adds the rolling average hashrate
windows the GUI asked for (1M/5M/15M/24H) end to end.

Core (asic-rs-core):
- New HashrateAverages sub-struct (data/hashrate.rs): avg_1m/5m/15m/24h, each an
  Option<HashRate> carrying the same unit and algorithm as the current hashrate.
- New DataField::HashrateAverages; MinerData gains hashrate_averages.
- The windows ride the EXISTING GetHashrate trait via a new defaulted
  parse_hashrate_averages method (default None), so no new supertrait bound and no
  empty impl in every backend -- only the backends that expose the data override
  it. parse_data wires it in.

Backends (all read a command the collector already fetches -> no extra round-trips;
each window is filtered to > 0 and the whole struct is dropped when every window is
absent, so a firmware that reports nothing keeps hashrate_averages = None):
- WhatsMiner V1: btminer summary MHS 1m/5m/15m (MegaHash); no 24h.
- WhatsMiner V3: get.miner.status summary hash-1min / hash-15min (TeraHash) only.
- LuxOS: summary GHS 1m/5m/15m/24h (GigaHash) -- full window set.
- Braiins v25_07 + v26_04: miner_stats real_hashrate last_1m/5m/15m/24h (GigaHash).
- Antminer (5s/30m/av only), WhatsMiner V2 (av only), ePIC/VNish (session average
  only), sealminer: no standard 1/5/15 window -> inherit None. This is honest: the
  fixtures confirm those firmwares do not expose the standard windows.

GUI: four new columns (HR 1m/5m/15m/24h), single TH/s value each, right-aligned,
blank when the window is not reported, auto-hidden when empty across the fleet.
MinerRow gains the four ths fields; to_row populates them from hashrate_averages.

Fixture tests: whatsminer v1 and braiins v26_04 gain assertions on the parsed
windows (value, unit, and the expected present/absent pattern). Patch 0025.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
This commit is contained in:
2026-09-23 15:08:27 -06:00
co-authored by Claude Opus 4.8
parent c944897807
commit a60bb34e64
16 changed files with 824 additions and 13 deletions
+52 -2
View File
@@ -496,6 +496,12 @@ pub struct MinerRow {
pub faults: Vec<Fault>,
// performance
pub hashrate_ths: f64,
/// 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,
pub hashrate_5m_ths: f64,
pub hashrate_15m_ths: f64,
pub hashrate_24h_ths: f64,
pub expected_ths: f64,
/// Per-hashboard hashrate in TH/s, index-aligned with the hashboards (index 0
/// = board 1). Drives the per-board Health tooltip (round 17 R2). Empty when
@@ -1047,6 +1053,14 @@ pub enum Column {
/// column picker or the display order; it exists only as a `sort` target the
/// Hashrate header cycles into.
HashrateRel,
/// Rolling average hashrate windows (round 19 #10, T2): 1m/5m/15m/24h, each a
/// single TH/s value. Populated per firmware where the API exposes the window
/// (LuxOS and Braiins report all four; WhatsMiner V1 1m/5m/15m, V3 1m/15m;
/// Antminer/ePIC/VNish report none). Auto-hidden when empty across the fleet.
Hashrate1m,
Hashrate5m,
Hashrate15m,
Hashrate24h,
Power,
ChipTemp,
// Per-fan RPM columns (round 19 #8): the old single "Fan (RPM)" column packed
@@ -1131,9 +1145,13 @@ pub enum Column {
/// Every column, in registry order. Ip first, then the default-visible set
/// (UI-SPEC order), then all remaining metrics.
pub const ALL_COLUMNS: [Column; 59] = [
pub const ALL_COLUMNS: [Column; 63] = [
Column::Ip,
Column::Hashrate,
Column::Hashrate1m,
Column::Hashrate5m,
Column::Hashrate15m,
Column::Hashrate24h,
Column::Health,
Column::Power,
Column::ChipTemp,
@@ -1218,6 +1236,10 @@ impl Column {
Column::Ip => "IP",
Column::Hashrate => "Hashrate",
Column::HashrateRel => "Rel. hashrate",
Column::Hashrate1m => "HR 1m",
Column::Hashrate5m => "HR 5m",
Column::Hashrate15m => "HR 15m",
Column::Hashrate24h => "HR 24h",
Column::Power => "Power",
Column::ChipTemp => "Chip temp",
Column::Fan1 => "Fan 1 (RPM)",
@@ -1288,6 +1310,9 @@ impl Column {
Column::Ip => 130,
Column::Hashrate => 110,
Column::HashrateRel => 110,
Column::Hashrate1m | Column::Hashrate5m | Column::Hashrate15m | Column::Hashrate24h => {
95
}
Column::Power => 90,
Column::ChipTemp | Column::FluidTemp | Column::EnvTemp | Column::OutletTemp => 95,
Column::Fan1 | Column::Fan2 | Column::Fan3 | Column::Fan4 | Column::PsuFan => 90,
@@ -1339,6 +1364,10 @@ impl Column {
self,
Column::Hashrate
| Column::HashrateRel
| Column::Hashrate1m
| Column::Hashrate5m
| Column::Hashrate15m
| Column::Hashrate24h
| Column::Power
| Column::Efficiency
| Column::ChipTemp
@@ -1400,6 +1429,20 @@ impl Column {
let none = f64::NEG_INFINITY;
match self {
Column::Hashrate => SortKey::Num(r.hashrate_ths),
// Rolling average windows; a 0.0 (window not reported) sorts to the
// bottom (round 19 #10, T2).
Column::Hashrate1m => {
SortKey::Num(if r.hashrate_1m_ths > 0.0 { r.hashrate_1m_ths } else { none })
}
Column::Hashrate5m => {
SortKey::Num(if r.hashrate_5m_ths > 0.0 { r.hashrate_5m_ths } else { none })
}
Column::Hashrate15m => {
SortKey::Num(if r.hashrate_15m_ths > 0.0 { r.hashrate_15m_ths } else { none })
}
Column::Hashrate24h => {
SortKey::Num(if r.hashrate_24h_ths > 0.0 { r.hashrate_24h_ths } else { none })
}
// Relative hashrate = actual/expected; unknown expectation sorts to
// the bottom (round 11 #16).
Column::HashrateRel => {
@@ -1464,6 +1507,12 @@ impl Column {
match self {
Column::Ip => r.ip.clone(),
Column::Hashrate => combined_si(r.hashrate_ths, 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(),
Column::Hashrate5m => format_hashrate_ths(r.hashrate_5m_ths).unwrap_or_default(),
Column::Hashrate15m => format_hashrate_ths(r.hashrate_15m_ths).unwrap_or_default(),
Column::Hashrate24h => format_hashrate_ths(r.hashrate_24h_ths).unwrap_or_default(),
// Never displayed as its own column; rendered as a percentage only for
// completeness (e.g. a debug/self-test read of the cell).
Column::HashrateRel => actual_expected_ratio(r.hashrate_ths, r.expected_ths)
@@ -1606,7 +1655,8 @@ impl Column {
Column::Health | Column::HealthPower | Column::HealthFans | Column::HealthBoards
| Column::Status | Column::Error | Column::Locked | Column::Light
| Column::OperatingState => (2, "Health & status"),
Column::Hashrate | Column::HashrateRel | Column::Power | Column::Efficiency
Column::Hashrate | Column::HashrateRel | Column::Hashrate1m | Column::Hashrate5m
| Column::Hashrate15m | Column::Hashrate24h | Column::Power | Column::Efficiency
| Column::TuningPercent | Column::BestShare | Column::SessionBestShare
| Column::Uptime | Column::Target | Column::BoardHashrate | Column::BoardVoltage
| Column::BoardFrequency => (3, "Performance"),
+25
View File
@@ -752,6 +752,27 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
.as_ref()
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
.unwrap_or(0.0);
// Rolling average windows in TH/s (round 19 #10, T2); 0.0 = window not reported.
let (hashrate_1m_ths, hashrate_5m_ths, hashrate_15m_ths, hashrate_24h_ths) = {
let to_ths = |h: &Option<asic_rs::core::data::hashrate::HashRate>| {
h.as_ref()
.map(|h| {
h.clone()
.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash)
.value
})
.unwrap_or(0.0)
};
match data.hashrate_averages.as_ref() {
Some(a) => (
to_ths(&a.avg_1m),
to_ths(&a.avg_5m),
to_ths(&a.avg_15m),
to_ths(&a.avg_24h),
),
None => (0.0, 0.0, 0.0, 0.0),
}
};
let mut expected_ths = data
.expected_hashrate
.as_ref()
@@ -1090,6 +1111,10 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
cpu,
board_code,
hashrate_ths,
hashrate_1m_ths,
hashrate_5m_ths,
hashrate_15m_ths,
hashrate_24h_ths,
expected_ths,
board_hashrates,
board_expected_hashrates,