Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64e084ddee |
@@ -75,6 +75,23 @@ pub fn format_hashrate_ths(ths: f64) -> Option<String> {
|
|||||||
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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`
|
||||||
|
/// recovers the real Sol/s count. SHA256/Scrypt show the TH/s value directly
|
||||||
|
/// ("33.5"); Equihash shows the Sol/s count with an SI prefix ("167.8K"). Pair
|
||||||
|
/// with [`MinerRow::hashrate_unit`]. `None` for a non-positive reading.
|
||||||
|
pub fn hashrate_num_for(algo: &str, ths: f64) -> Option<String> {
|
||||||
|
if ths <= 0.0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if algo.eq_ignore_ascii_case("equihash") {
|
||||||
|
si_mantissa_and_prefix(ths * 1e12).map(|(num, prefix)| format!("{num}{prefix}"))
|
||||||
|
} else {
|
||||||
|
Some(format!("{ths:.1}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The actual/expected ratio, or `None` when the expected value is unknown
|
/// The actual/expected ratio, or `None` when the expected value is unknown
|
||||||
/// (<= 0.0) so a ratio-based color/warning never divides by zero or treats an
|
/// (<= 0.0) so a ratio-based color/warning never divides by zero or treats an
|
||||||
/// unknown expectation as a 0% shortfall.
|
/// unknown expectation as a 0% shortfall.
|
||||||
@@ -762,9 +779,11 @@ impl MinerRow {
|
|||||||
let num = n - 1 - i; // count down, left to right
|
let num = n - 1 - i; // count down, left to right
|
||||||
let actual = self.board_hashrates.get(i).copied().unwrap_or(0.0);
|
let actual = self.board_hashrates.get(i).copied().unwrap_or(0.0);
|
||||||
let expected = self.board_expected_hashrates.get(i).copied().unwrap_or(0.0);
|
let expected = self.board_expected_hashrates.get(i).copied().unwrap_or(0.0);
|
||||||
match (actual > 0.0, expected > 0.0) {
|
let a = hashrate_num_for(&self.algorithm, actual);
|
||||||
(true, true) => format!("{num} \u{00b7} {actual:.1} / {expected:.1} {unit}"),
|
let e = hashrate_num_for(&self.algorithm, expected);
|
||||||
(true, false) => format!("{num} \u{00b7} {actual:.1} {unit}"),
|
match (a, e) {
|
||||||
|
(Some(a), Some(e)) => format!("{num} \u{00b7} {a} / {e} {unit}"),
|
||||||
|
(Some(a), None) => format!("{num} \u{00b7} {a} {unit}"),
|
||||||
_ => num.to_string(),
|
_ => num.to_string(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1800,6 +1819,20 @@ mod tests {
|
|||||||
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn equihash_hashrate_units_round18() {
|
||||||
|
// SHA256 shows the TH/s value directly; Equihash shows the Sol/s count
|
||||||
|
// (ths * 1e12) with an SI prefix (round 18 #7).
|
||||||
|
assert_eq!(hashrate_num_for("SHA256", 80.5).as_deref(), Some("80.5"));
|
||||||
|
// 167,764 Sol/s -> SI mantissa+prefix ("168k"); paired with the "Sol/s" unit.
|
||||||
|
assert_eq!(hashrate_num_for("Equihash", 167_764.0 / 1e12).as_deref(), Some("168k"));
|
||||||
|
assert_eq!(hashrate_num_for("Equihash", 0.0), None);
|
||||||
|
let sha = MinerRow { algorithm: "SHA256".into(), ..Default::default() };
|
||||||
|
let equi = MinerRow { algorithm: "Equihash".into(), ..Default::default() };
|
||||||
|
assert_eq!(sha.hashrate_unit(), "TH/s");
|
||||||
|
assert_eq!(equi.hashrate_unit(), "Sol/s");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn health_tooltips_are_bare_data_round17_r2() {
|
fn health_tooltips_are_bare_data_round17_r2() {
|
||||||
// R2: operating boards show their number counting DOWN (n-1..0) left to
|
// R2: operating boards show their number counting DOWN (n-1..0) left to
|
||||||
|
|||||||
@@ -287,6 +287,22 @@ fn is_aml_140mm(clean_model: &str) -> bool {
|
|||||||
m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21")
|
m.contains("XP") || m.starts_with("S19k") || m.starts_with("S21")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Nameplate expected hashrate in Sol/s for an Equihash (Zcash) miner model, when
|
||||||
|
/// the firmware itself does not report an expected hashrate (round 18 #6). Plain
|
||||||
|
/// Antminer Z15 firmware omits the cgminer `total_rateideal` field (the Z15j does
|
||||||
|
/// report it), so its actual-vs-expected column and colour would otherwise be
|
||||||
|
/// blank. The Z15 nameplate is 420 KSol/s. Returns `None` for models with no known
|
||||||
|
/// nameplate (the caller then leaves expected unknown).
|
||||||
|
pub fn equihash_expected_sols(clean_model: &str) -> Option<f64> {
|
||||||
|
let m = clean_model.to_ascii_lowercase();
|
||||||
|
// Match the Z15 family (z15, z15j); both share the 420 KSol/s nameplate.
|
||||||
|
if m.contains("z15") {
|
||||||
|
Some(420_000.0)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
.unwrap_or(0.0);
|
.unwrap_or(0.0);
|
||||||
let expected_ths = data
|
let mut expected_ths = data
|
||||||
.expected_hashrate
|
.expected_hashrate
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
@@ -711,6 +711,14 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
.filter_map(|f| f.rpm.as_ref().map(|r| r.as_rpm()))
|
.filter_map(|f| f.rpm.as_ref().map(|r| r.as_rpm()))
|
||||||
.fold(0.0f64, f64::max);
|
.fold(0.0f64, f64::max);
|
||||||
let algorithm = data.hashrate.as_ref().map(|h| h.algo.to_string()).unwrap_or_default();
|
let algorithm = data.hashrate.as_ref().map(|h| h.algo.to_string()).unwrap_or_default();
|
||||||
|
// Equihash (Z15) fallback: plain Z15 firmware omits the expected hashrate, so
|
||||||
|
// fill it from the model nameplate (Sol/s -> the ths-normalised value) so the
|
||||||
|
// actual/expected column + colour work like every other miner (round 18 #6).
|
||||||
|
if expected_ths <= 0.0 && algorithm.eq_ignore_ascii_case("equihash") {
|
||||||
|
if let Some(sols) = crate::naming::equihash_expected_sols(&model) {
|
||||||
|
expected_ths = sols / 1e12;
|
||||||
|
}
|
||||||
|
}
|
||||||
let is_mining = data.is_mining;
|
let is_mining = data.is_mining;
|
||||||
let slow = crate::model::is_slow(is_mining, hashrate_ths, expected_ths);
|
let slow = crate::model::is_slow(is_mining, hashrate_ths, expected_ths);
|
||||||
let operating_state = data.operating_state.as_ref().map(|s| s.to_string()).unwrap_or_default();
|
let operating_state = data.operating_state.as_ref().map(|s| s.to_string()).unwrap_or_default();
|
||||||
|
|||||||
@@ -1311,14 +1311,16 @@ impl App {
|
|||||||
// With a single algorithm running (the common case) the card shows that
|
// With a single algorithm running (the common case) the card shows that
|
||||||
// algorithm's total under a "<Algo> Hashrate" caption; when several are
|
// algorithm's total under a "<Algo> Hashrate" caption; when several are
|
||||||
// running, clicking the card cycles `hashrate_algo_idx` through them.
|
// running, clicking the card cycles `hashrate_algo_idx` through them.
|
||||||
let (algo_label, algo_ths) = if k.hashrate_by_algo.is_empty() {
|
let (algo_label, algo_ths, algo_unit) = if k.hashrate_by_algo.is_empty() {
|
||||||
("SHA-256".to_string(), 0.0)
|
("SHA-256".to_string(), 0.0, "H")
|
||||||
} else {
|
} else {
|
||||||
let i = self.hashrate_algo_idx % k.hashrate_by_algo.len();
|
let i = self.hashrate_algo_idx % k.hashrate_by_algo.len();
|
||||||
let (a, t) = &k.hashrate_by_algo[i];
|
let (a, t) = &k.hashrate_by_algo[i];
|
||||||
(pretty_algo(a), *t)
|
// Equihash miners (Z15/Zcash) are counted in Sol/s, not H/s (round 18 #7).
|
||||||
|
let unit = if a.eq_ignore_ascii_case("equihash") { "Sol" } else { "H" };
|
||||||
|
(pretty_algo(a), *t, unit)
|
||||||
};
|
};
|
||||||
self.kpi_hashrate.set_label(&format_si(algo_ths * 1e12, "H"));
|
self.kpi_hashrate.set_label(&format_si(algo_ths * 1e12, algo_unit));
|
||||||
self.kpi_hashrate_lbl.set_label(&format!("{algo_label} Hashrate"));
|
self.kpi_hashrate_lbl.set_label(&format!("{algo_label} Hashrate"));
|
||||||
self.kpi_power.set_label(&format_si(k.total_power_w, "W"));
|
self.kpi_power.set_label(&format_si(k.total_power_w, "W"));
|
||||||
// set_label resizes the static text; re-run each card's sizer so the
|
// set_label resizes the static text; re-run each card's sizer so the
|
||||||
|
|||||||
@@ -983,6 +983,17 @@ static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keybo
|
|||||||
if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
|
if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
|
||||||
const wxString& tip = iit->second[(size_t)slot];
|
const wxString& tip = iit->second[(size_t)slot];
|
||||||
if (tip.IsEmpty()) return FALSE;
|
if (tip.IsEmpty()) return FALSE;
|
||||||
|
// Scope the tooltip's "tip area" to just this icon's slot (round 18 #4a).
|
||||||
|
// Without a tip area GTK defaults it to the whole widget, so it never re-queries
|
||||||
|
// or moves the tooltip as the pointer crosses from one icon to the next -- the
|
||||||
|
// old tooltip just stays put with stale text. Setting a per-slot area makes GTK
|
||||||
|
// hide + re-show + reposition the tooltip for each icon.
|
||||||
|
GdkRectangle area;
|
||||||
|
area.x = crect.x + slot * adv;
|
||||||
|
area.y = crect.y;
|
||||||
|
area.width = adv;
|
||||||
|
area.height = crect.height;
|
||||||
|
gtk_tooltip_set_tip_area(tooltip, &area);
|
||||||
gtk_tooltip_set_text(tooltip, tip.utf8_str());
|
gtk_tooltip_set_text(tooltip, tip.utf8_str());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user