Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34a1a1f3b1 | ||
|
|
0db89d6c55 | ||
|
|
08b3d56864 | ||
|
|
4e825f3ee5 | ||
|
|
8e67c50fe0 | ||
|
|
da0d1582be | ||
|
|
7f802c568f |
@@ -62,6 +62,18 @@ async fn scan(cidrs: &[String]) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// Cap identification concurrency to match the GUI (see
|
||||||
|
// scan::SCAN_CONCURRENCY_LIMIT). asic-rs defaults to 1000, which over a real
|
||||||
|
// link starves the per-responder get_data -- Braiins miners drop most values
|
||||||
|
// (watts=0, no best-share) and some responders are missed entirely. 128 is the
|
||||||
|
// highest cap that stayed fully reliable on the live fleet. ALKANE_PROBE_CONCURRENCY
|
||||||
|
// overrides it for diagnostics.
|
||||||
|
let concurrency = std::env::var("ALKANE_PROBE_CONCURRENCY")
|
||||||
|
.ok()
|
||||||
|
.and_then(|c| c.parse::<usize>().ok())
|
||||||
|
.unwrap_or(128);
|
||||||
|
eprintln!("(scan concurrency = {concurrency})");
|
||||||
|
f = f.with_concurrent_limit(concurrency);
|
||||||
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
||||||
let mut stream = f.scan_stream_with_ip();
|
let mut stream = f.scan_stream_with_ip();
|
||||||
let mut found = 0usize;
|
let mut found = 0usize;
|
||||||
@@ -263,6 +275,9 @@ async fn msgs(ip_s: &str) {
|
|||||||
match f.scan_miner(ip).await {
|
match f.scan_miner(ip).await {
|
||||||
Ok(Some(m)) => {
|
Ok(Some(m)) => {
|
||||||
let d = m.get_data().await;
|
let d = m.get_data().await;
|
||||||
|
let th = |h: &Option<asic_rs::core::data::hashrate::HashRate>| {
|
||||||
|
h.clone().map(|x| x.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
|
};
|
||||||
println!(
|
println!(
|
||||||
"{ip}: {} {} hashboards={:?} expected={:?}",
|
"{ip}: {} {} hashboards={:?} expected={:?}",
|
||||||
d.device_info.firmware,
|
d.device_info.firmware,
|
||||||
@@ -270,13 +285,28 @@ async fn msgs(ip_s: &str) {
|
|||||||
d.hashboards.len(),
|
d.hashboards.len(),
|
||||||
d.expected_hashboards,
|
d.expected_hashboards,
|
||||||
);
|
);
|
||||||
|
println!(
|
||||||
|
" TOTAL hashrate={:?} TH wattage={:?} W fluid/env_temp={:?} best_share={:?}",
|
||||||
|
th(&d.hashrate),
|
||||||
|
d.wattage.as_ref().map(|p| p.as_watts()),
|
||||||
|
d.fluid_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
d.best_share,
|
||||||
|
);
|
||||||
|
let fans: Vec<i64> = d
|
||||||
|
.fans
|
||||||
|
.iter()
|
||||||
|
.map(|f| f.rpm.as_ref().map(|r| r.as_rpm() as i64).unwrap_or(-1))
|
||||||
|
.collect();
|
||||||
|
println!(" fans(rpm)={fans:?} psu_fans={}", d.psu_fans.len());
|
||||||
for b in d.hashboards.iter() {
|
for b in d.hashboards.iter() {
|
||||||
println!(
|
println!(
|
||||||
" board position={} hashrate={:?} chips={:?}/{:?}",
|
" board pos={} hr={:?}TH chips={:?}/{:?} board_temp={:?} outlet_temp={:?}",
|
||||||
b.position,
|
b.position,
|
||||||
b.hashrate.clone().map(|h| h.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value),
|
th(&b.hashrate),
|
||||||
b.working_chips,
|
b.working_chips,
|
||||||
b.expected_chips,
|
b.expected_chips,
|
||||||
|
b.board_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
b.outlet_chip_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if d.messages.is_empty() {
|
if d.messages.is_empty() {
|
||||||
@@ -436,6 +466,137 @@ async fn factoryreset(ip_s: &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// READ-ONLY: dump a miner's structured-tuning surface -- what it supports, its
|
||||||
|
/// current target, and the capability envelope (power/hashrate min-max, or the
|
||||||
|
/// preset/mode list) the firmware advertises. Drives the round-17 C tuning work:
|
||||||
|
/// it shows what each live firmware actually offers before any write is wired up.
|
||||||
|
async fn tune(ip_s: &str) {
|
||||||
|
let ip: std::net::IpAddr = match ip_s.parse() {
|
||||||
|
Ok(ip) => ip,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("bad ip {ip_s}: {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let f = factory();
|
||||||
|
match f.scan_miner(ip).await {
|
||||||
|
Ok(Some(m)) => {
|
||||||
|
let data = m.get_data().await;
|
||||||
|
println!(
|
||||||
|
"{ip}: {} {} {}",
|
||||||
|
data.device_info.make, data.device_info.firmware, data.device_info.model
|
||||||
|
);
|
||||||
|
println!(
|
||||||
|
" supports: power_limit={} tuning_percent={} tuning_config={}",
|
||||||
|
m.supports_set_power_limit(),
|
||||||
|
m.supports_set_tuning_percent(),
|
||||||
|
m.supports_tuning_config(),
|
||||||
|
);
|
||||||
|
println!(" tuning_percent={:?}", data.tuning_percent);
|
||||||
|
println!(" tuning_target={:?}", data.tuning_target);
|
||||||
|
match &data.tuning_capabilities {
|
||||||
|
Some(c) => {
|
||||||
|
println!(" caps.power={:?}", c.power);
|
||||||
|
println!(" caps.hashrate={:?}", c.hashrate);
|
||||||
|
match &c.presets {
|
||||||
|
Some(p) => {
|
||||||
|
println!(" caps.presets.default={:?}", p.default);
|
||||||
|
println!(" caps.presets[{}]:", p.presets.len());
|
||||||
|
for t in &p.presets {
|
||||||
|
println!(" - {t:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => println!(" caps.presets=None"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => println!(" tuning_capabilities=None"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(None) => eprintln!("no miner at {ip}"),
|
||||||
|
Err(e) => eprintln!("scan_miner {ip}: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// WRITE (reversible): apply a structured tuning target via set_tuning_config.
|
||||||
|
/// `settune <ip> power <watts>` or `settune <ip> hashrate <ths>`. Prints the
|
||||||
|
/// prior target so the caller can restore it. Used to verify the set_tuning_config
|
||||||
|
/// path on live corpus hardware (round 17 C) before wiring it into the GUI.
|
||||||
|
async fn settune(ip_s: &str, kind: &str, value: f64) {
|
||||||
|
use asic_rs::core::config::tuning::TuningConfig;
|
||||||
|
use asic_rs::core::data::hashrate::HashRateUnit;
|
||||||
|
use asic_rs::core::data::miner::TuningTarget;
|
||||||
|
let ip: std::net::IpAddr = match ip_s.parse() {
|
||||||
|
Ok(ip) => ip,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("bad ip {ip_s}: {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let f = factory();
|
||||||
|
match f.scan_miner(ip).await {
|
||||||
|
Ok(Some(m)) => {
|
||||||
|
let before = m.get_data().await;
|
||||||
|
eprintln!(
|
||||||
|
"target {ip}: {} {} {} (supports_tuning_config={}); prior target = {:?}",
|
||||||
|
before.device_info.make,
|
||||||
|
before.device_info.firmware,
|
||||||
|
before.device_info.model,
|
||||||
|
m.supports_tuning_config(),
|
||||||
|
before.tuning_target,
|
||||||
|
);
|
||||||
|
let target = match kind {
|
||||||
|
"power" => TuningTarget::Power(Power::from_watts(value)),
|
||||||
|
// Clone the miner's current HashRate to inherit its algorithm
|
||||||
|
// (HashAlgorithm is not publicly re-exported, so it cannot be named
|
||||||
|
// directly), overriding just the value and unit.
|
||||||
|
"hashrate" => match before.hashrate.clone() {
|
||||||
|
Some(mut hr) => {
|
||||||
|
hr.value = value;
|
||||||
|
hr.unit = HashRateUnit::TeraHash;
|
||||||
|
TuningTarget::HashRate(hr)
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("miner reports no current hashrate; cannot build a hashrate target");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
eprintln!("kind must be 'power' or 'hashrate'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Route by what the firmware actually supports: structured
|
||||||
|
// set_tuning_config where available (ePIC/VNish/WM), else the plain
|
||||||
|
// power-limit setter for a power target (LuxOS/Braiins tune by power
|
||||||
|
// and expose no set_tuning_config).
|
||||||
|
if m.supports_tuning_config() {
|
||||||
|
// Mirror the GUI apply path: preserve the firmware's current tuning
|
||||||
|
// algorithm + scaling (ePIC requires both for set_tuning_config).
|
||||||
|
let mut cfg = TuningConfig::new(target);
|
||||||
|
if let Some(algo) = m.get_tuning_config().await.ok().and_then(|c| c.algorithm) {
|
||||||
|
cfg = cfg.with_algorithm(algo);
|
||||||
|
}
|
||||||
|
let scaling = m.get_scaling_config().await.ok();
|
||||||
|
match m.set_tuning_config(cfg, scaling).await {
|
||||||
|
Ok(v) => println!("set_tuning_config({kind} {value}) -> Ok({v})"),
|
||||||
|
Err(e) => println!("set_tuning_config({kind} {value}) -> Err: {e:#}"),
|
||||||
|
}
|
||||||
|
} else if kind == "power" && m.supports_set_power_limit() {
|
||||||
|
match m.set_power_limit(Power::from_watts(value)).await {
|
||||||
|
Ok(v) => println!("set_power_limit({value} W) -> Ok({v}) [tuning_config unsupported]"),
|
||||||
|
Err(e) => println!("set_power_limit({value} W) -> Err: {e:#}"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("no structured-tuning path for {kind} on this firmware");
|
||||||
|
}
|
||||||
|
let after = m.get_data().await;
|
||||||
|
println!(" target now = {:?}", after.tuning_target);
|
||||||
|
}
|
||||||
|
Ok(None) => eprintln!("no miner at {ip}"),
|
||||||
|
Err(e) => eprintln!("scan_miner {ip}: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
||||||
@@ -467,6 +628,15 @@ fn main() {
|
|||||||
rt.block_on(setpools(&args[2], &args[3], &args[4], &args[5]))
|
rt.block_on(setpools(&args[2], &args[3], &args[4], &args[5]))
|
||||||
}
|
}
|
||||||
Some("msgs") if args.len() == 3 => rt.block_on(msgs(&args[2])),
|
Some("msgs") if args.len() == 3 => rt.block_on(msgs(&args[2])),
|
||||||
|
Some("tune") if args.len() == 3 => rt.block_on(tune(&args[2])),
|
||||||
|
Some("settune") if args.len() == 5 && matches!(args[3].as_str(), "power" | "hashrate") => {
|
||||||
|
let value: f64 = args[4].parse().unwrap_or(-1.0);
|
||||||
|
if value <= 0.0 {
|
||||||
|
eprintln!("value must be a positive number");
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
|
rt.block_on(settune(&args[2], &args[3], value));
|
||||||
|
}
|
||||||
Some("timezone") if args.len() == 3 => rt.block_on(timezone(&args[2], None)),
|
Some("timezone") if args.len() == 3 => rt.block_on(timezone(&args[2], None)),
|
||||||
Some("timezone") if args.len() == 4 => rt.block_on(timezone(&args[2], Some(&args[3]))),
|
Some("timezone") if args.len() == 4 => rt.block_on(timezone(&args[2], Some(&args[3]))),
|
||||||
Some("passwd") if args.len() == 4 => rt.block_on(passwd(&args[2], &args[3])),
|
Some("passwd") if args.len() == 4 => rt.block_on(passwd(&args[2], &args[3])),
|
||||||
@@ -479,6 +649,7 @@ fn main() {
|
|||||||
\x20 scan <cidr> [<cidr>...] discover + telemetry (TSV)\n\
|
\x20 scan <cidr> [<cidr>...] discover + telemetry (TSV)\n\
|
||||||
\x20 hashrate <cidr> [<cidr>...] raw hashrate/algo dump\n\
|
\x20 hashrate <cidr> [<cidr>...] raw hashrate/algo dump\n\
|
||||||
\x20 msgs <ip> structured faults + per-board data\n\
|
\x20 msgs <ip> structured faults + per-board data\n\
|
||||||
|
\x20 tune <ip> structured-tuning support + capability envelope\n\
|
||||||
\n\
|
\n\
|
||||||
WRITE (MUTATES the miner -- use the test-bed miners, not production):\n\
|
WRITE (MUTATES the miner -- use the test-bed miners, not production):\n\
|
||||||
\x20 light <ip> <on|off> set the locate light\n\
|
\x20 light <ip> <on|off> set the locate light\n\
|
||||||
@@ -487,6 +658,7 @@ fn main() {
|
|||||||
\x20 resume <ip> resume mining\n\
|
\x20 resume <ip> resume mining\n\
|
||||||
\x20 restart <ip> restart/reboot\n\
|
\x20 restart <ip> restart/reboot\n\
|
||||||
\x20 setpl <ip> <watts> set power limit\n\
|
\x20 setpl <ip> <watts> set power limit\n\
|
||||||
|
\x20 settune <ip> <power|hashrate> <v> set a structured tuning target (prints prior)\n\
|
||||||
\x20 setpools <ip> <url> <user> <pass> set the default pool group\n\
|
\x20 setpools <ip> <url> <user> <pass> set the default pool group\n\
|
||||||
\x20 timezone <ip> [<IANA>] read (no arg) or set the timezone\n\
|
\x20 timezone <ip> [<IANA>] read (no arg) or set the timezone\n\
|
||||||
\x20 passwd <ip> <newpass> change the web/API password (DANGEROUS)\n\
|
\x20 passwd <ip> <newpass> change the web/API password (DANGEROUS)\n\
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ impl Board {
|
|||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
};
|
};
|
||||||
|
// Per-board hashrate for the R2 Health tooltip demo: split the total three
|
||||||
|
// ways with a little variety (index-aligned with the 3 boards).
|
||||||
|
let board_hashrates = if self.mining && self.hashrate > 0.0 {
|
||||||
|
vec![self.hashrate * 0.34, self.hashrate * 0.35, self.hashrate * 0.31]
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
// Air-cooled WhatsMiners report an ambient reading (asic-rs surfaces it in
|
// Air-cooled WhatsMiners report an ambient reading (asic-rs surfaces it in
|
||||||
// its fluid_temperature field); the scan routes it to env_temp for
|
// its fluid_temperature field); the scan routes it to env_temp for
|
||||||
// air-cooled models, so the demo mirrors that (round 11 #17).
|
// air-cooled models, so the demo mirrors that (round 11 #17).
|
||||||
@@ -109,6 +116,7 @@ impl Board {
|
|||||||
board_code,
|
board_code,
|
||||||
hashrate_ths: self.hashrate,
|
hashrate_ths: self.hashrate,
|
||||||
expected_ths: self.expected,
|
expected_ths: self.expected,
|
||||||
|
board_hashrates,
|
||||||
efficiency,
|
efficiency,
|
||||||
power_w: self.power,
|
power_w: self.power,
|
||||||
chip_temp_c: self.temp,
|
chip_temp_c: self.temp,
|
||||||
@@ -157,6 +165,7 @@ impl Board {
|
|||||||
resume: self.mining,
|
resume: self.mining,
|
||||||
power_limit: self.mining,
|
power_limit: self.mining,
|
||||||
tuning: self.mining,
|
tuning: self.mining,
|
||||||
|
hashrate_target: self.mining,
|
||||||
firmware_flash,
|
firmware_flash,
|
||||||
pools: true,
|
pools: true,
|
||||||
timezone: self.mining,
|
timezone: self.mining,
|
||||||
|
|||||||
+165
-74
@@ -213,6 +213,10 @@ pub struct MinerCaps {
|
|||||||
pub resume: bool,
|
pub resume: bool,
|
||||||
pub power_limit: bool,
|
pub power_limit: bool,
|
||||||
pub tuning: bool,
|
pub tuning: bool,
|
||||||
|
/// Round 17 C: supports setting a structured hashrate target via
|
||||||
|
/// `set_tuning_config` (the firmware actively tunes by hashrate, e.g. ePIC).
|
||||||
|
/// Power targets are covered by `power_limit`.
|
||||||
|
pub hashrate_target: bool,
|
||||||
/// Whether this miner's asic-rs driver supports `upgrade_firmware`
|
/// Whether this miner's asic-rs driver supports `upgrade_firmware`
|
||||||
/// (probed via `supports_upgrade_firmware()` at scan time).
|
/// (probed via `supports_upgrade_firmware()` at scan time).
|
||||||
pub firmware_flash: bool,
|
pub firmware_flash: bool,
|
||||||
@@ -236,6 +240,7 @@ impl MinerCaps {
|
|||||||
resume: self.resume && other.resume,
|
resume: self.resume && other.resume,
|
||||||
power_limit: self.power_limit && other.power_limit,
|
power_limit: self.power_limit && other.power_limit,
|
||||||
tuning: self.tuning && other.tuning,
|
tuning: self.tuning && other.tuning,
|
||||||
|
hashrate_target: self.hashrate_target && other.hashrate_target,
|
||||||
firmware_flash: self.firmware_flash && other.firmware_flash,
|
firmware_flash: self.firmware_flash && other.firmware_flash,
|
||||||
pools: self.pools && other.pools,
|
pools: self.pools && other.pools,
|
||||||
timezone: self.timezone && other.timezone,
|
timezone: self.timezone && other.timezone,
|
||||||
@@ -268,6 +273,7 @@ impl MinerCaps {
|
|||||||
|| self.resume
|
|| self.resume
|
||||||
|| self.power_limit
|
|| self.power_limit
|
||||||
|| self.tuning
|
|| self.tuning
|
||||||
|
|| self.hashrate_target
|
||||||
|| self.firmware_flash
|
|| self.firmware_flash
|
||||||
|| self.pools
|
|| self.pools
|
||||||
|| self.timezone
|
|| self.timezone
|
||||||
@@ -306,10 +312,26 @@ pub enum FaultComponent {
|
|||||||
pub struct Fault {
|
pub struct Fault {
|
||||||
pub component: FaultComponent,
|
pub component: FaultComponent,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
|
/// Firmware's numeric error code for this message, or 0 when none. Shown in
|
||||||
|
/// the tooltip alongside the text (round 17 R2) so an operator can look the
|
||||||
|
/// code up.
|
||||||
|
pub code: u64,
|
||||||
/// True for Error severity; false for Warning. (Info is dropped upstream.)
|
/// True for Error severity; false for Warning. (Info is dropped upstream.)
|
||||||
pub is_error: bool,
|
pub is_error: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Fault {
|
||||||
|
/// The tooltip line for this fault: the message, with the firmware error code
|
||||||
|
/// appended when there is one (round 17 R2).
|
||||||
|
pub fn display_line(&self) -> String {
|
||||||
|
if self.code != 0 {
|
||||||
|
format!("{} (code {})", self.message, self.code)
|
||||||
|
} else {
|
||||||
|
self.message.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
||||||
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
||||||
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
||||||
@@ -394,9 +416,29 @@ pub struct MinerRow {
|
|||||||
// performance
|
// performance
|
||||||
pub hashrate_ths: f64,
|
pub hashrate_ths: f64,
|
||||||
pub expected_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
|
||||||
|
/// the firmware reports no per-board hashrate.
|
||||||
|
pub board_hashrates: Vec<f64>,
|
||||||
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
||||||
pub efficiency: f64,
|
pub efficiency: f64,
|
||||||
pub power_w: f64,
|
pub power_w: f64,
|
||||||
|
/// PSU output voltage/current, when the firmware reports them (round 17 R2 /
|
||||||
|
/// roadmap G15). `None` until the PSU-info scan lands; the power tooltip then
|
||||||
|
/// shows "V / A" for a healthy PSU instead of a bare "PSU OK".
|
||||||
|
pub psu_out_voltage_v: Option<f64>,
|
||||||
|
pub psu_out_current_a: Option<f64>,
|
||||||
|
/// Current structured tuning target, rendered for display (e.g. "2832 W",
|
||||||
|
/// "96 TH/s", "preset 3550"), or None (round 17 C).
|
||||||
|
pub tuning_target_label: Option<String>,
|
||||||
|
/// Advertised power-target envelope in watts, when the firmware reports one
|
||||||
|
/// (round 17 C, e.g. Braiins 944-6435 W). Bounds + validate the power-target
|
||||||
|
/// prompt; `None` leaves it unbounded.
|
||||||
|
pub power_target_min_w: Option<f64>,
|
||||||
|
pub power_target_max_w: Option<f64>,
|
||||||
|
/// Advertised hashrate-target envelope in TH/s, when reported (round 17 C).
|
||||||
|
pub hashrate_target_min_ths: Option<f64>,
|
||||||
|
pub hashrate_target_max_ths: Option<f64>,
|
||||||
pub tuning_percent: Option<u8>,
|
pub tuning_percent: Option<u8>,
|
||||||
// thermal / cooling
|
// thermal / cooling
|
||||||
/// Average chip temperature (used for sorting/colour banding of the
|
/// Average chip temperature (used for sorting/colour banding of the
|
||||||
@@ -625,7 +667,7 @@ impl MinerRow {
|
|||||||
self.faults
|
self.faults
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| f.component == component)
|
.filter(|f| f.component == component)
|
||||||
.map(|f| f.message.clone())
|
.map(|f| f.display_line())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +677,7 @@ impl MinerRow {
|
|||||||
self.faults
|
self.faults
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|f| matches!(f.component, FaultComponent::Other | FaultComponent::Control))
|
.filter(|f| matches!(f.component, FaultComponent::Other | FaultComponent::Control))
|
||||||
.map(|f| f.message.clone())
|
.map(|f| f.display_line())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,84 +688,86 @@ impl MinerRow {
|
|||||||
/// reports for that component.
|
/// reports for that component.
|
||||||
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
||||||
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
||||||
// Power -- the bolt icon carries any power-supply faults (round 16 #2).
|
// Power (bolt). A working PSU shows its output voltage + amperage when the
|
||||||
|
// firmware reports them (else a short OK); a faulted one shows the error
|
||||||
|
// and code instead (round 17 R2). asic-rs does not yet surface PSU output
|
||||||
|
// V/A (roadmap G15), so `psu_output` is None until that lands and the OK
|
||||||
|
// branch shows just the status.
|
||||||
let power_faults = self.fault_texts_for(FaultComponent::Power);
|
let power_faults = self.fault_texts_for(FaultComponent::Power);
|
||||||
let mut power = format!(
|
if !power_faults.is_empty() {
|
||||||
"Power supply: {}",
|
tips.push(power_faults.join("\n"));
|
||||||
match self.power_health() {
|
} else {
|
||||||
CompHealth::Ok => "OK (drawing power)",
|
tips.push(match (self.power_health(), self.psu_output_label()) {
|
||||||
CompHealth::Down if !power_faults.is_empty() => "fault reported",
|
(CompHealth::Ok, Some(va)) => va,
|
||||||
CompHealth::Down => "detected but not delivering",
|
(CompHealth::Ok, None) => "PSU OK".to_string(),
|
||||||
CompHealth::Degraded => "sub-optimal",
|
(CompHealth::Degraded, _) => "PSU sub-optimal".to_string(),
|
||||||
CompHealth::Unreachable => "unknown (no wattage/PSU-fan reported)",
|
(CompHealth::Down, _) => "PSU not delivering".to_string(),
|
||||||
}
|
(CompHealth::Unreachable, _) => "PSU unknown".to_string(),
|
||||||
);
|
});
|
||||||
for e in &power_faults {
|
|
||||||
power.push('\n');
|
|
||||||
power.push_str(e);
|
|
||||||
}
|
}
|
||||||
tips.push(power);
|
// Control board (brain) -- its own and the miner's un-attributed faults
|
||||||
// Control board -- also carries the miner's un-attributed / control faults.
|
// with codes; a short OK when clean.
|
||||||
let mut ctl = format!(
|
let ctl_faults = self.general_fault_texts();
|
||||||
"Control board: {}",
|
if !ctl_faults.is_empty() {
|
||||||
match self.control_health() {
|
tips.push(ctl_faults.join("\n"));
|
||||||
CompHealth::Ok => "OK (miner reachable)",
|
} else {
|
||||||
CompHealth::Degraded => "miner-level fault",
|
tips.push(match self.control_health() {
|
||||||
CompHealth::Down => "fault reported",
|
CompHealth::Ok => "Control board OK".to_string(),
|
||||||
CompHealth::Unreachable => "unknown",
|
_ => "Control board fault".to_string(),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
for e in self.general_fault_texts() {
|
|
||||||
ctl.push('\n');
|
|
||||||
ctl.push_str(&e);
|
|
||||||
}
|
}
|
||||||
tips.push(ctl);
|
// Fans -- just the RPM, unless the fan has a fault (then the error+code).
|
||||||
// Fans.
|
|
||||||
let fans = self.fan_healths();
|
let fans = self.fan_healths();
|
||||||
for i in 0..max_fans {
|
for i in 0..max_fans {
|
||||||
let s = match fans.get(i) {
|
let fault = self.fault_texts_for(FaultComponent::Fan(i));
|
||||||
Some(CompHealth::Ok) => {
|
let t = if !fault.is_empty() {
|
||||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
fault.join("\n")
|
||||||
format!("spinning{rpm}")
|
} else {
|
||||||
|
match fans.get(i) {
|
||||||
|
Some(_) => format!("{:.0} rpm", self.fan_rpms.get(i).copied().unwrap_or(0.0)),
|
||||||
|
None => String::new(), // padding slot for fleet alignment
|
||||||
}
|
}
|
||||||
Some(CompHealth::Degraded) => {
|
|
||||||
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
|
||||||
format!("slow{rpm}")
|
|
||||||
}
|
|
||||||
Some(CompHealth::Down) => "stopped (0 rpm)".to_string(),
|
|
||||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
|
||||||
None => "not present".to_string(),
|
|
||||||
};
|
};
|
||||||
let mut t = format!("Fan {}: {s}", i + 1);
|
|
||||||
for e in self.fault_texts_for(FaultComponent::Fan(i)) {
|
|
||||||
t.push('\n');
|
|
||||||
t.push_str(&e);
|
|
||||||
}
|
|
||||||
tips.push(t);
|
tips.push(t);
|
||||||
}
|
}
|
||||||
// Hashboards. When the PSU has failed the boards can't be tested, so they
|
// Hashboards -- an operating board shows its number (counting DOWN, n-1..0,
|
||||||
// read "unpowered" (grey) rather than "faulted" (round 16 #2/#3).
|
// left to right) and hashrate; a faulted board shows its error+code; a
|
||||||
|
// board the failed PSU left untested shows "unpowered" (round 17 R2,
|
||||||
|
// round 16 #2/#3). No generic "Hashboard N: faulted" prose.
|
||||||
let boards = self.board_healths();
|
let boards = self.board_healths();
|
||||||
let psu_down = self.power_supply_faulted();
|
let psu_down = self.power_supply_faulted();
|
||||||
|
let n = self.hashboards.map(|v| v as usize).unwrap_or(boards.len());
|
||||||
for i in 0..max_boards {
|
for i in 0..max_boards {
|
||||||
let s = match boards.get(i) {
|
let fault = self.fault_texts_for(FaultComponent::Board(i));
|
||||||
Some(CompHealth::Ok) => "hashing".to_string(),
|
let t = if !fault.is_empty() {
|
||||||
Some(CompHealth::Degraded) => "hashing sub-optimally".to_string(),
|
fault.join("\n")
|
||||||
Some(CompHealth::Down) => "faulted".to_string(),
|
} else if matches!(boards.get(i), Some(CompHealth::Unreachable)) && psu_down {
|
||||||
Some(CompHealth::Unreachable) if psu_down => "unpowered (PSU fault)".to_string(),
|
"unpowered (PSU fault)".to_string()
|
||||||
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
} else if i < n {
|
||||||
None => "not present".to_string(),
|
let num = n - 1 - i; // count down, left to right
|
||||||
|
match self.board_hashrates.get(i).copied() {
|
||||||
|
Some(hr) if hr > 0.0 => format!("{num} \u{00b7} {hr:.1} TH/s"),
|
||||||
|
_ => num.to_string(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String::new() // padding slot for fleet alignment
|
||||||
};
|
};
|
||||||
let mut t = format!("Hashboard {}: {s}", i + 1);
|
|
||||||
for e in self.fault_texts_for(FaultComponent::Board(i)) {
|
|
||||||
t.push('\n');
|
|
||||||
t.push_str(&e);
|
|
||||||
}
|
|
||||||
tips.push(t);
|
tips.push(t);
|
||||||
}
|
}
|
||||||
tips
|
tips
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The PSU output "V / A" tooltip label when the firmware reports it, else
|
||||||
|
/// None. asic-rs does not yet expose PSU output voltage/current (roadmap G15),
|
||||||
|
/// so this is a forward-compatible hook that stays None for now (round 17 R2).
|
||||||
|
fn psu_output_label(&self) -> Option<String> {
|
||||||
|
match (self.psu_out_voltage_v, self.psu_out_current_a) {
|
||||||
|
(Some(v), Some(a)) if v > 0.0 => Some(format!("{v:.1} V \u{00b7} {a:.1} A")),
|
||||||
|
(Some(v), None) if v > 0.0 => Some(format!("{v:.1} V")),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Compact plain-text summary of component health (round 13 #3), used as the
|
/// Compact plain-text summary of component health (round 13 #3), used as the
|
||||||
/// Health column's filter/sort-fallback text and the base of its hover
|
/// Health column's filter/sort-fallback text and the base of its hover
|
||||||
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
||||||
@@ -1221,11 +1265,20 @@ impl Column {
|
|||||||
Column::Cpu => r.cpu.clone(),
|
Column::Cpu => r.cpu.clone(),
|
||||||
Column::BoardCode => r.board_code.clone(),
|
Column::BoardCode => r.board_code.clone(),
|
||||||
Column::Algorithm => r.algorithm.clone(),
|
Column::Algorithm => r.algorithm.clone(),
|
||||||
Column::Pic => match r.pic_present {
|
Column::Pic => {
|
||||||
Some(true) => "PIC".to_string(),
|
// A per-board PIC MCU is an Antminer hashboard property; it has no
|
||||||
Some(false) => "noPIC".to_string(),
|
// meaning for WhatsMiner or any other make, which show nothing
|
||||||
None => "?".to_string(),
|
// rather than a "?" that implies an unanswered Antminer question.
|
||||||
},
|
if !r.brand.eq_ignore_ascii_case("antminer") {
|
||||||
|
String::new()
|
||||||
|
} else {
|
||||||
|
match r.pic_present {
|
||||||
|
Some(true) => "PIC".to_string(),
|
||||||
|
Some(false) => "noPIC".to_string(),
|
||||||
|
None => "?".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Column::Locked => match r.write_locked {
|
Column::Locked => match r.write_locked {
|
||||||
Some(true) => "locked".to_string(),
|
Some(true) => "locked".to_string(),
|
||||||
Some(false) => "unlocked".to_string(),
|
Some(false) => "unlocked".to_string(),
|
||||||
@@ -1645,6 +1698,7 @@ mod tests {
|
|||||||
let fault = |c: FaultComponent, m: &str| Fault {
|
let fault = |c: FaultComponent, m: &str| Fault {
|
||||||
component: c,
|
component: c,
|
||||||
message: m.to_string(),
|
message: m.to_string(),
|
||||||
|
code: 0,
|
||||||
is_error: true,
|
is_error: true,
|
||||||
};
|
};
|
||||||
let r = MinerRow {
|
let r = MinerRow {
|
||||||
@@ -1687,6 +1741,41 @@ mod tests {
|
|||||||
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn health_tooltips_are_bare_data_round17_r2() {
|
||||||
|
// R2: operating boards show their number counting DOWN (n-1..0) left to
|
||||||
|
// right plus hashrate; fans show just RPM; a fault shows the message with
|
||||||
|
// its code; no "Hashboard N: faulted" prose.
|
||||||
|
let r = MinerRow {
|
||||||
|
is_mining: true,
|
||||||
|
hashboards: Some(3),
|
||||||
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Fault],
|
||||||
|
board_hashrates: vec![33.5, 34.6, 0.0],
|
||||||
|
expected_fans: Some(2),
|
||||||
|
fan_rpms: vec![4700.0, 4650.0],
|
||||||
|
power_w: 3000.0,
|
||||||
|
faults: vec![Fault {
|
||||||
|
component: FaultComponent::Board(2),
|
||||||
|
message: "Slot 2 chip failure.".to_string(),
|
||||||
|
code: 540,
|
||||||
|
is_error: true,
|
||||||
|
}],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let tips = r.health_tooltips(2, 3);
|
||||||
|
// power OK (no V/A yet), control OK, 2 fans, 3 boards.
|
||||||
|
assert_eq!(tips[0], "PSU OK");
|
||||||
|
assert_eq!(tips[1], "Control board OK");
|
||||||
|
assert_eq!(tips[2], "4700 rpm");
|
||||||
|
assert_eq!(tips[3], "4650 rpm");
|
||||||
|
// Boards count DOWN left->right: leftmost = 2, then 1, then 0.
|
||||||
|
assert!(tips[4].starts_with("2") && tips[4].contains("33.5 TH/s"), "{}", tips[4]);
|
||||||
|
assert!(tips[5].starts_with("1") && tips[5].contains("34.6 TH/s"), "{}", tips[5]);
|
||||||
|
// The faulted board shows its error WITH the code, no "Hashboard" prose.
|
||||||
|
assert!(tips[6].contains("Slot 2 chip failure.") && tips[6].contains("540"), "{}", tips[6]);
|
||||||
|
assert!(!tips[6].to_lowercase().contains("hashboard"), "{}", tips[6]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn kpis_match_expected_hardware_output() {
|
fn kpis_match_expected_hardware_output() {
|
||||||
// This does not hardcode fixture counts: it independently recomputes
|
// This does not hardcode fixture counts: it independently recomputes
|
||||||
@@ -1984,13 +2073,14 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pic_locked_error_columns_render() {
|
fn pic_locked_error_columns_render() {
|
||||||
// PIC (best-effort): known -> PIC/noPIC, unknown -> "?".
|
// PIC (best-effort): Antminer known -> PIC/noPIC, unknown Antminer -> "?".
|
||||||
let pic = MinerRow { pic_present: Some(true), ..Default::default() };
|
let am = |pic| MinerRow { brand: "Antminer".into(), pic_present: pic, ..Default::default() };
|
||||||
let nopic = MinerRow { pic_present: Some(false), ..Default::default() };
|
assert_eq!(Column::Pic.cell(&am(Some(true))), "PIC");
|
||||||
let pic_unknown = MinerRow { pic_present: None, ..Default::default() };
|
assert_eq!(Column::Pic.cell(&am(Some(false))), "noPIC");
|
||||||
assert_eq!(Column::Pic.cell(&pic), "PIC");
|
assert_eq!(Column::Pic.cell(&am(None)), "?");
|
||||||
assert_eq!(Column::Pic.cell(&nopic), "noPIC");
|
// Non-Antminer makes: PIC has no meaning -> blank, never "?".
|
||||||
assert_eq!(Column::Pic.cell(&pic_unknown), "?");
|
let wm = MinerRow { brand: "WhatsMiner".into(), pic_present: None, ..Default::default() };
|
||||||
|
assert_eq!(Column::Pic.cell(&wm), "");
|
||||||
|
|
||||||
// Access column.
|
// Access column.
|
||||||
let locked = MinerRow { write_locked: Some(true), ..Default::default() };
|
let locked = MinerRow { write_locked: Some(true), ..Default::default() };
|
||||||
@@ -2253,6 +2343,7 @@ mod tests {
|
|||||||
resume: true,
|
resume: true,
|
||||||
power_limit: true,
|
power_limit: true,
|
||||||
tuning: true,
|
tuning: true,
|
||||||
|
hashrate_target: true,
|
||||||
firmware_flash: true,
|
firmware_flash: true,
|
||||||
pools: true,
|
pools: true,
|
||||||
timezone: true,
|
timezone: true,
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ pub const AUTO_FILE: &str = "auto-rescan-secs.txt";
|
|||||||
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
||||||
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
||||||
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
||||||
|
/// Maximum in-flight address probes during a scan. asic-rs would otherwise use
|
||||||
|
/// 1000 for any range up to /22, saturating a real link and starving the
|
||||||
|
/// per-responder get_data (Braiins miners drop most values under that burst).
|
||||||
|
/// 128 was the highest cap that stayed fully reliable on the live fleet.
|
||||||
|
pub const SCAN_CONCURRENCY_LIMIT: usize = 128;
|
||||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
||||||
/// Default seconds between automatic rescans.
|
/// Default seconds between automatic rescans.
|
||||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||||
@@ -377,7 +382,18 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
};
|
};
|
||||||
rt.block_on(async move {
|
rt.block_on(async move {
|
||||||
let mut factory = crate::credentials::configured_factory()
|
let mut factory = crate::credentials::configured_factory()
|
||||||
.with_identification_timeout_secs(timeout_secs.max(1));
|
.with_identification_timeout_secs(timeout_secs.max(1))
|
||||||
|
// Cap identification concurrency. asic-rs defaults to 1000 for any
|
||||||
|
// range up to /22, so a /24 fires all 254 probes at once. Over a
|
||||||
|
// real link (VPN, or a subnet full of dead IPs whose TCP connects
|
||||||
|
// sit open for the whole identification timeout) that burst starves
|
||||||
|
// the per-responder get_data -- a Braiins miner fans out ~12
|
||||||
|
// authenticated REST calls and drops most of its values (watts=0,
|
||||||
|
// no best-share/temps), and some responders are missed entirely.
|
||||||
|
// 128 is the highest cap that stayed fully reliable on the live
|
||||||
|
// fleet (192 already dropped responders); a /24 still finishes in
|
||||||
|
// ~35s. Larger ranges just take proportionally longer, still correct.
|
||||||
|
.with_concurrent_limit(SCAN_CONCURRENCY_LIMIT);
|
||||||
for (ip, prefix) in &cidrs {
|
for (ip, prefix) in &cidrs {
|
||||||
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
@@ -391,7 +407,10 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
// get accurate progress plus the responders.
|
// get accurate progress plus the responders.
|
||||||
let mut stream = factory.scan_stream_with_ip();
|
let mut stream = factory.scan_stream_with_ip();
|
||||||
let mut done = 0usize;
|
let mut done = 0usize;
|
||||||
let step = (total / 100).max(1); // throttle progress messages
|
// Emit progress per address for a smoothly-climbing counter; only a
|
||||||
|
// very large scan (> 5000 addresses) is throttled, to bound channel
|
||||||
|
// traffic. The UI coalesces these to one gauge update per refresh.
|
||||||
|
let step = (total / 5000).max(1);
|
||||||
while let Some((ip, miner)) = stream.next().await {
|
while let Some((ip, miner)) = stream.next().await {
|
||||||
if thread_cancel.load(Ordering::Relaxed) {
|
if thread_cancel.load(Ordering::Relaxed) {
|
||||||
return; // Stop / re-scan requested
|
return; // Stop / re-scan requested
|
||||||
@@ -486,6 +505,7 @@ fn messages_to_faults(
|
|||||||
Some(Fault {
|
Some(Fault {
|
||||||
component,
|
component,
|
||||||
message: text.to_string(),
|
message: text.to_string(),
|
||||||
|
code: m.code,
|
||||||
is_error,
|
is_error,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -554,6 +574,20 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
})
|
})
|
||||||
.filter(|&t| t > 0.0)
|
.filter(|&t| t > 0.0)
|
||||||
.collect();
|
.collect();
|
||||||
|
// Per-board hashrate (TH/s), index-aligned with the hashboards, for the
|
||||||
|
// per-board Health tooltip (round 17 R2). Unlike board_temps this is NOT
|
||||||
|
// filtered/compacted -- index i must stay board i so the tooltip numbering
|
||||||
|
// lines up.
|
||||||
|
let board_hashrates: Vec<f64> = data
|
||||||
|
.hashboards
|
||||||
|
.iter()
|
||||||
|
.map(|b| {
|
||||||
|
b.hashrate
|
||||||
|
.as_ref()
|
||||||
|
.map(|h| h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
|
.unwrap_or(0.0)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let fan_rpms: Vec<f64> = data
|
let fan_rpms: Vec<f64> = data
|
||||||
.fans
|
.fans
|
||||||
.iter()
|
.iter()
|
||||||
@@ -641,6 +675,47 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
// VNish; Braiins and the rest keep asic-rs's answer.
|
// VNish; Braiins and the rest keep asic-rs's answer.
|
||||||
let power_limit = miner.supports_set_power_limit()
|
let power_limit = miner.supports_set_power_limit()
|
||||||
&& !data.device_info.firmware.eq_ignore_ascii_case("VNish");
|
&& !data.device_info.firmware.eq_ignore_ascii_case("VNish");
|
||||||
|
// Structured tuning (round 17 C). Extract the current target + the advertised
|
||||||
|
// envelope so the "Set performance target" prompt can show/validate bounds.
|
||||||
|
use asic_rs::core::data::miner::TuningTarget;
|
||||||
|
let target_watts = |t: &TuningTarget| match t {
|
||||||
|
TuningTarget::Power(p) => Some(p.as_watts()),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let target_ths = |t: &TuningTarget| match t {
|
||||||
|
TuningTarget::HashRate(h) => Some(
|
||||||
|
h.clone()
|
||||||
|
.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash)
|
||||||
|
.value,
|
||||||
|
),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let (power_target_min_w, power_target_max_w, hashrate_target_min_ths, hashrate_target_max_ths) =
|
||||||
|
match &data.tuning_capabilities {
|
||||||
|
Some(c) => (
|
||||||
|
c.power.as_ref().and_then(|p| p.minimum.as_ref()).and_then(&target_watts),
|
||||||
|
c.power.as_ref().and_then(|p| p.maximum.as_ref()).and_then(&target_watts),
|
||||||
|
c.hashrate.as_ref().and_then(|h| h.minimum.as_ref()).and_then(&target_ths),
|
||||||
|
c.hashrate.as_ref().and_then(|h| h.maximum.as_ref()).and_then(&target_ths),
|
||||||
|
),
|
||||||
|
None => (None, None, None, None),
|
||||||
|
};
|
||||||
|
let tuning_target_label = data.tuning_target.as_ref().map(|t| match t {
|
||||||
|
TuningTarget::Power(p) => format!("{:.0} W", p.as_watts()),
|
||||||
|
TuningTarget::HashRate(h) => format!(
|
||||||
|
"{:.0} TH/s",
|
||||||
|
h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value
|
||||||
|
),
|
||||||
|
TuningTarget::MiningMode(m) => format!("mode {m}"),
|
||||||
|
TuningTarget::Preset(s) => format!("preset {s}"),
|
||||||
|
TuningTarget::Manual { .. } => "manual".to_string(),
|
||||||
|
});
|
||||||
|
// A hashrate target is offerable only where the firmware actively tunes by
|
||||||
|
// hashrate through set_tuning_config (ePIC); Braiins advertises a hashrate
|
||||||
|
// envelope but has no set_tuning_config wired, so it is excluded.
|
||||||
|
let tunes_by_hashrate = matches!(data.tuning_target, Some(TuningTarget::HashRate(_)))
|
||||||
|
|| data.tuning_capabilities.as_ref().map(|c| c.hashrate.is_some()).unwrap_or(false);
|
||||||
|
let hashrate_target = miner.supports_tuning_config() && tunes_by_hashrate;
|
||||||
// Probe what this miner supports being told to do (sync, no extra I/O).
|
// Probe what this miner supports being told to do (sync, no extra I/O).
|
||||||
let caps = MinerCaps {
|
let caps = MinerCaps {
|
||||||
fault_light: miner.supports_set_fault_light(),
|
fault_light: miner.supports_set_fault_light(),
|
||||||
@@ -649,6 +724,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
resume: miner.supports_resume(),
|
resume: miner.supports_resume(),
|
||||||
power_limit,
|
power_limit,
|
||||||
tuning: miner.supports_set_tuning_percent(),
|
tuning: miner.supports_set_tuning_percent(),
|
||||||
|
hashrate_target,
|
||||||
firmware_flash: miner.supports_upgrade_firmware(),
|
firmware_flash: miner.supports_upgrade_firmware(),
|
||||||
pools: miner.supports_pools_config(),
|
pools: miner.supports_pools_config(),
|
||||||
timezone: miner.supports_timezone_config(),
|
timezone: miner.supports_timezone_config(),
|
||||||
@@ -732,8 +808,18 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
|||||||
board_code,
|
board_code,
|
||||||
hashrate_ths,
|
hashrate_ths,
|
||||||
expected_ths,
|
expected_ths,
|
||||||
|
board_hashrates,
|
||||||
efficiency: data.efficiency.unwrap_or(0.0),
|
efficiency: data.efficiency.unwrap_or(0.0),
|
||||||
power_w,
|
power_w,
|
||||||
|
// PSU output V/A is not yet exposed by asic-rs (roadmap G15); the tooltip
|
||||||
|
// falls back to a status string until it is.
|
||||||
|
psu_out_voltage_v: None,
|
||||||
|
psu_out_current_a: None,
|
||||||
|
tuning_target_label,
|
||||||
|
power_target_min_w,
|
||||||
|
power_target_max_w,
|
||||||
|
hashrate_target_min_ths,
|
||||||
|
hashrate_target_max_ths,
|
||||||
tuning_percent: data.tuning_percent,
|
tuning_percent: data.tuning_percent,
|
||||||
chip_temp_c,
|
chip_temp_c,
|
||||||
board_temps,
|
board_temps,
|
||||||
@@ -771,7 +857,8 @@ pub enum ConfigAction {
|
|||||||
Restart,
|
Restart,
|
||||||
Pause,
|
Pause,
|
||||||
Resume,
|
Resume,
|
||||||
PowerLimit(f64), // watts
|
PowerLimit(f64), // watts
|
||||||
|
HashRateTarget(f64), // TH/s -- structured hashrate target (round 17 C)
|
||||||
TuningPercent(u8),
|
TuningPercent(u8),
|
||||||
Timezone(String), // IANA zone, e.g. "America/Edmonton" (round 17 B / G10)
|
Timezone(String), // IANA zone, e.g. "America/Edmonton" (round 17 B / G10)
|
||||||
ChangePassword(String), // new web/API password (round 17 B / G11)
|
ChangePassword(String), // new web/API password (round 17 B / G11)
|
||||||
@@ -787,7 +874,8 @@ impl ConfigAction {
|
|||||||
ConfigAction::Restart => "restart".into(),
|
ConfigAction::Restart => "restart".into(),
|
||||||
ConfigAction::Pause => "pause".into(),
|
ConfigAction::Pause => "pause".into(),
|
||||||
ConfigAction::Resume => "resume".into(),
|
ConfigAction::Resume => "resume".into(),
|
||||||
ConfigAction::PowerLimit(w) => format!("power limit {w:.0} W"),
|
ConfigAction::PowerLimit(w) => format!("power target {w:.0} W"),
|
||||||
|
ConfigAction::HashRateTarget(t) => format!("hashrate target {t:.0} TH/s"),
|
||||||
ConfigAction::TuningPercent(p) => format!("tuning {p}%"),
|
ConfigAction::TuningPercent(p) => format!("tuning {p}%"),
|
||||||
ConfigAction::Timezone(tz) => format!("timezone {tz}"),
|
ConfigAction::Timezone(tz) => format!("timezone {tz}"),
|
||||||
ConfigAction::ChangePassword(_) => "change password".into(),
|
ConfigAction::ChangePassword(_) => "change password".into(),
|
||||||
@@ -805,6 +893,7 @@ impl ConfigAction {
|
|||||||
ConfigAction::Pause => "pausing…".into(),
|
ConfigAction::Pause => "pausing…".into(),
|
||||||
ConfigAction::Resume => "resuming…".into(),
|
ConfigAction::Resume => "resuming…".into(),
|
||||||
ConfigAction::PowerLimit(_) => "setting power…".into(),
|
ConfigAction::PowerLimit(_) => "setting power…".into(),
|
||||||
|
ConfigAction::HashRateTarget(_) => "setting hashrate…".into(),
|
||||||
ConfigAction::TuningPercent(_) => "tuning…".into(),
|
ConfigAction::TuningPercent(_) => "tuning…".into(),
|
||||||
ConfigAction::Timezone(_) => "setting timezone…".into(),
|
ConfigAction::Timezone(_) => "setting timezone…".into(),
|
||||||
ConfigAction::ChangePassword(_) => "changing password…".into(),
|
ConfigAction::ChangePassword(_) => "changing password…".into(),
|
||||||
@@ -839,6 +928,28 @@ async fn apply_action(miner: &dyn Miner, action: &ConfigAction) -> Result<bool,
|
|||||||
ConfigAction::Pause => miner.pause(None).await,
|
ConfigAction::Pause => miner.pause(None).await,
|
||||||
ConfigAction::Resume => miner.resume(None).await,
|
ConfigAction::Resume => miner.resume(None).await,
|
||||||
ConfigAction::PowerLimit(w) => miner.set_power_limit(Power::from_watts(*w)).await,
|
ConfigAction::PowerLimit(w) => miner.set_power_limit(Power::from_watts(*w)).await,
|
||||||
|
ConfigAction::HashRateTarget(ths) => {
|
||||||
|
use asic_rs::core::config::tuning::TuningConfig;
|
||||||
|
use asic_rs::core::data::hashrate::HashRateUnit;
|
||||||
|
use asic_rs::core::data::miner::TuningTarget;
|
||||||
|
// Build a HashRate target by cloning the miner's current hashrate to
|
||||||
|
// inherit its algorithm (HashAlgorithm is not publicly nameable),
|
||||||
|
// overriding value + unit.
|
||||||
|
let data = miner.get_data().await;
|
||||||
|
let Some(mut hr) = data.hashrate.clone() else {
|
||||||
|
return Err("miner reports no current hashrate; cannot set a hashrate target".into());
|
||||||
|
};
|
||||||
|
hr.value = *ths;
|
||||||
|
hr.unit = HashRateUnit::TeraHash;
|
||||||
|
let mut cfg = TuningConfig::new(TuningTarget::HashRate(hr));
|
||||||
|
// Preserve the firmware's current tuning algorithm + scaling (ePIC
|
||||||
|
// requires both for set_tuning_config; other firmware ignore them).
|
||||||
|
if let Some(algo) = miner.get_tuning_config().await.ok().and_then(|c| c.algorithm) {
|
||||||
|
cfg = cfg.with_algorithm(algo);
|
||||||
|
}
|
||||||
|
let scaling = miner.get_scaling_config().await.ok();
|
||||||
|
miner.set_tuning_config(cfg, scaling).await
|
||||||
|
}
|
||||||
ConfigAction::TuningPercent(p) => miner.set_tuning_percent(*p).await,
|
ConfigAction::TuningPercent(p) => miner.set_tuning_percent(*p).await,
|
||||||
ConfigAction::Timezone(tz) => {
|
ConfigAction::Timezone(tz) => {
|
||||||
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
|
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
|
||||||
|
|||||||
+128
-12
@@ -66,6 +66,7 @@ const ID_CTX_PAUSE: i32 = 725;
|
|||||||
const ID_CTX_RESUME: i32 = 726;
|
const ID_CTX_RESUME: i32 = 726;
|
||||||
const ID_CTX_TUNING: i32 = 727;
|
const ID_CTX_TUNING: i32 = 727;
|
||||||
const ID_CTX_POWER: i32 = 728;
|
const ID_CTX_POWER: i32 = 728;
|
||||||
|
const ID_CTX_HASHRATE: i32 = 740; // Set hashrate target (round 17 C)
|
||||||
const ID_CTX_RESTART: i32 = 729;
|
const ID_CTX_RESTART: i32 = 729;
|
||||||
// Round 17 B: timezone / change-password / factory-reset config actions.
|
// Round 17 B: timezone / change-password / factory-reset config actions.
|
||||||
const ID_CTX_TIMEZONE: i32 = 737;
|
const ID_CTX_TIMEZONE: i32 = 737;
|
||||||
@@ -97,6 +98,7 @@ const ID_ACTION_CANCEL: i32 = 741;
|
|||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
enum PromptKind {
|
enum PromptKind {
|
||||||
Power,
|
Power,
|
||||||
|
HashRateTarget,
|
||||||
Tuning,
|
Tuning,
|
||||||
Timezone,
|
Timezone,
|
||||||
Password,
|
Password,
|
||||||
@@ -128,6 +130,11 @@ const ID_HDR_SORT_REL_DESC: i32 = 766;
|
|||||||
const ID_FILTER_COL: i32 = 730;
|
const ID_FILTER_COL: i32 = 730;
|
||||||
const ID_FILTER_OP: i32 = 731;
|
const ID_FILTER_OP: i32 = 731;
|
||||||
const TIMER_SCAN: i32 = 1;
|
const TIMER_SCAN: i32 = 1;
|
||||||
|
/// The scan/drain timer fires this often (ms). A fast tick drains the scan channel
|
||||||
|
/// several times a second so the progress counter climbs smoothly instead of
|
||||||
|
/// jumping ~1%/s; the once-per-second scheduler work runs every `TICKS_PER_SEC`.
|
||||||
|
const TICK_MS: i32 = 200;
|
||||||
|
const TICKS_PER_SEC: u64 = 1000 / TICK_MS as u64;
|
||||||
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
|
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
|
||||||
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
|
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
|
||||||
const DEFER_TABLE: i32 = 1;
|
const DEFER_TABLE: i32 = 1;
|
||||||
@@ -640,6 +647,9 @@ pub struct App {
|
|||||||
// Per-miner scan timeout in seconds (round 14 #2).
|
// Per-miner scan timeout in seconds (round 14 #2).
|
||||||
scan_timeout_secs: u64,
|
scan_timeout_secs: u64,
|
||||||
countdown: u64,
|
countdown: u64,
|
||||||
|
/// Counts fast timer ticks; the once-per-second scheduler runs every
|
||||||
|
/// `TICKS_PER_SEC` of these (the drains run every tick for smooth progress).
|
||||||
|
tick_accum: u64,
|
||||||
// selection (replaces the old checkbox column), tracked by IP so it
|
// selection (replaces the old checkbox column), tracked by IP so it
|
||||||
// survives table refreshes during a scan.
|
// survives table refreshes during a scan.
|
||||||
selected_ips: HashSet<String>,
|
selected_ips: HashSet<String>,
|
||||||
@@ -983,6 +993,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
auto_secs: scan::load_auto_secs(),
|
auto_secs: scan::load_auto_secs(),
|
||||||
scan_timeout_secs: scan::load_scan_timeout(),
|
scan_timeout_secs: scan::load_scan_timeout(),
|
||||||
countdown: 0,
|
countdown: 0,
|
||||||
|
tick_accum: 0,
|
||||||
selected_ips: HashSet::new(),
|
selected_ips: HashSet::new(),
|
||||||
pal,
|
pal,
|
||||||
kpi_cards,
|
kpi_cards,
|
||||||
@@ -1057,7 +1068,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
app.view = p.view.to_view();
|
app.view = p.view.to_view();
|
||||||
}
|
}
|
||||||
app.rebuild_table();
|
app.rebuild_table();
|
||||||
Widget::timer(TIMER_SCAN, 1000);
|
Widget::timer(TIMER_SCAN, TICK_MS);
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1474,7 +1485,10 @@ impl App {
|
|||||||
menu.menu_append(ID_CTX_TUNING, &format!("Set tuning %...{sfx}"));
|
menu.menu_append(ID_CTX_TUNING, &format!("Set tuning %...{sfx}"));
|
||||||
}
|
}
|
||||||
if caps.power_limit {
|
if caps.power_limit {
|
||||||
menu.menu_append(ID_CTX_POWER, &format!("Set power limit...{sfx}"));
|
menu.menu_append(ID_CTX_POWER, &format!("Set power target...{sfx}"));
|
||||||
|
}
|
||||||
|
if caps.hashrate_target {
|
||||||
|
menu.menu_append(ID_CTX_HASHRATE, &format!("Set hashrate target...{sfx}"));
|
||||||
}
|
}
|
||||||
if caps.restart {
|
if caps.restart {
|
||||||
menu.menu_append(ID_CTX_RESTART, &format!("Restart{sfx}"));
|
menu.menu_append(ID_CTX_RESTART, &format!("Restart{sfx}"));
|
||||||
@@ -2106,6 +2120,7 @@ impl App {
|
|||||||
ID_CTX_RESTART => return Some(self.build_confirm_dialog(scan::ConfigAction::Restart)),
|
ID_CTX_RESTART => return Some(self.build_confirm_dialog(scan::ConfigAction::Restart)),
|
||||||
// Value entry is itself the confirmation.
|
// Value entry is itself the confirmation.
|
||||||
ID_CTX_POWER => return Some(self.build_action_prompt(PromptKind::Power)),
|
ID_CTX_POWER => return Some(self.build_action_prompt(PromptKind::Power)),
|
||||||
|
ID_CTX_HASHRATE => return Some(self.build_action_prompt(PromptKind::HashRateTarget)),
|
||||||
ID_CTX_TUNING => return Some(self.build_action_prompt(PromptKind::Tuning)),
|
ID_CTX_TUNING => return Some(self.build_action_prompt(PromptKind::Tuning)),
|
||||||
ID_CTX_TIMEZONE => return Some(self.build_action_prompt(PromptKind::Timezone)),
|
ID_CTX_TIMEZONE => return Some(self.build_action_prompt(PromptKind::Timezone)),
|
||||||
ID_CTX_PASSWORD => return Some(self.build_action_prompt(PromptKind::Password)),
|
ID_CTX_PASSWORD => return Some(self.build_action_prompt(PromptKind::Password)),
|
||||||
@@ -2156,21 +2171,81 @@ impl App {
|
|||||||
|
|
||||||
/// A small modal to enter a power limit (watts) or tuning percent for the
|
/// A small modal to enter a power limit (watts) or tuning percent for the
|
||||||
/// selection. Built here, shown modally by `dispatch` outside the App borrow.
|
/// selection. Built here, shown modally by `dispatch` outside the App borrow.
|
||||||
|
/// The tightest common tuning envelope (max of the mins .. min of the maxes)
|
||||||
|
/// across the captured-selection miners that advertise one, plus their shared
|
||||||
|
/// current-target label ("varies" if they differ), for the target prompts
|
||||||
|
/// (round 17 C). `get` picks the (min, max) pair for the target kind.
|
||||||
|
fn selected_envelope(
|
||||||
|
&self,
|
||||||
|
get: impl Fn(&MinerRow) -> (Option<f64>, Option<f64>),
|
||||||
|
) -> (Option<(f64, f64)>, Option<String>) {
|
||||||
|
let sel = self
|
||||||
|
.rows
|
||||||
|
.iter()
|
||||||
|
.filter(|r| self.action_ips.contains(&r.ip));
|
||||||
|
let mut lo: Option<f64> = None;
|
||||||
|
let mut hi: Option<f64> = None;
|
||||||
|
let mut labels: std::collections::HashSet<String> = std::collections::HashSet::new();
|
||||||
|
for r in sel {
|
||||||
|
let (mn, mx) = get(r);
|
||||||
|
if let Some(m) = mn {
|
||||||
|
lo = Some(lo.map_or(m, |v: f64| v.max(m)));
|
||||||
|
}
|
||||||
|
if let Some(m) = mx {
|
||||||
|
hi = Some(hi.map_or(m, |v: f64| v.min(m)));
|
||||||
|
}
|
||||||
|
if let Some(l) = &r.tuning_target_label {
|
||||||
|
labels.insert(l.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let range = match (lo, hi) {
|
||||||
|
(Some(a), Some(b)) if a <= b => Some((a, b)),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
let label = match labels.len() {
|
||||||
|
0 => None,
|
||||||
|
1 => labels.into_iter().next(),
|
||||||
|
_ => Some("varies".to_string()),
|
||||||
|
};
|
||||||
|
(range, label)
|
||||||
|
}
|
||||||
|
|
||||||
fn build_action_prompt(&mut self, kind: PromptKind) -> Widget {
|
fn build_action_prompt(&mut self, kind: PromptKind) -> Widget {
|
||||||
self.action_ips = self.selected_ip_list();
|
self.action_ips = self.selected_ip_list();
|
||||||
self.action_kind = kind;
|
self.action_kind = kind;
|
||||||
let n = self.action_ips.len();
|
let n = self.action_ips.len();
|
||||||
let frame = Widget::main_frame();
|
let frame = Widget::main_frame();
|
||||||
let title = match kind {
|
let title = match kind {
|
||||||
PromptKind::Power => "Set power limit",
|
PromptKind::Power => "Set power target",
|
||||||
|
PromptKind::HashRateTarget => "Set hashrate target",
|
||||||
PromptKind::Tuning => "Set tuning percent",
|
PromptKind::Tuning => "Set tuning percent",
|
||||||
PromptKind::Timezone => "Set timezone",
|
PromptKind::Timezone => "Set timezone",
|
||||||
PromptKind::Password => "Change password",
|
PromptKind::Password => "Change password",
|
||||||
};
|
};
|
||||||
let dlg = Widget::dialog(frame, title);
|
let dlg = Widget::dialog(frame, title);
|
||||||
let root = Widget::box_sizer(true);
|
let root = Widget::box_sizer(true);
|
||||||
|
// Append the current target and the advertised valid range to the target
|
||||||
|
// prompts (round 17 C), so the operator sees what the firmware will accept.
|
||||||
|
let target_hint = |range: Option<(f64, f64)>, cur: Option<String>, unit: &str| {
|
||||||
|
let mut s = String::new();
|
||||||
|
if let Some(c) = cur {
|
||||||
|
s.push_str(&format!("\nCurrent: {c}."));
|
||||||
|
}
|
||||||
|
if let Some((a, b)) = range {
|
||||||
|
s.push_str(&format!(" Valid range: {a:.0}-{b:.0} {unit}."));
|
||||||
|
}
|
||||||
|
s
|
||||||
|
};
|
||||||
let lbl = match kind {
|
let lbl = match kind {
|
||||||
PromptKind::Power => format!("Power limit in watts for {n} miner(s):"),
|
PromptKind::Power => {
|
||||||
|
let (range, cur) = self.selected_envelope(|r| (r.power_target_min_w, r.power_target_max_w));
|
||||||
|
format!("Power target in watts for {n} miner(s):{}", target_hint(range, cur, "W"))
|
||||||
|
}
|
||||||
|
PromptKind::HashRateTarget => {
|
||||||
|
let (range, cur) =
|
||||||
|
self.selected_envelope(|r| (r.hashrate_target_min_ths, r.hashrate_target_max_ths));
|
||||||
|
format!("Hashrate target in TH/s for {n} miner(s):{}", target_hint(range, cur, "TH/s"))
|
||||||
|
}
|
||||||
PromptKind::Tuning => format!("Tuning percent (0-100) for {n} miner(s):"),
|
PromptKind::Tuning => format!("Tuning percent (0-100) for {n} miner(s):"),
|
||||||
PromptKind::Timezone => format!("IANA timezone (e.g. America/Edmonton) for {n} miner(s):"),
|
PromptKind::Timezone => format!("IANA timezone (e.g. America/Edmonton) for {n} miner(s):"),
|
||||||
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
||||||
@@ -2197,9 +2272,35 @@ impl App {
|
|||||||
/// captured selection) so the operator can correct it.
|
/// captured selection) so the operator can correct it.
|
||||||
fn apply_action_prompt(&mut self) {
|
fn apply_action_prompt(&mut self) {
|
||||||
let val = self.action_input.get_value();
|
let val = self.action_input.get_value();
|
||||||
|
// A target must be positive, finite, and within the advertised range when
|
||||||
|
// one exists (round 17 C).
|
||||||
|
let in_range = |v: f64, range: Option<(f64, f64)>| {
|
||||||
|
v > 0.0 && v.is_finite() && range.map_or(true, |(a, b)| v >= a && v <= b)
|
||||||
|
};
|
||||||
let action = match self.action_kind {
|
let action = match self.action_kind {
|
||||||
PromptKind::Power => match val.trim().parse::<f64>() {
|
PromptKind::Power => match val.trim().parse::<f64>() {
|
||||||
Ok(w) if w > 0.0 && w.is_finite() => Some(scan::ConfigAction::PowerLimit(w)),
|
Ok(w)
|
||||||
|
if in_range(
|
||||||
|
w,
|
||||||
|
self.selected_envelope(|r| (r.power_target_min_w, r.power_target_max_w)).0,
|
||||||
|
) =>
|
||||||
|
{
|
||||||
|
Some(scan::ConfigAction::PowerLimit(w))
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
PromptKind::HashRateTarget => match val.trim().parse::<f64>() {
|
||||||
|
Ok(t)
|
||||||
|
if in_range(
|
||||||
|
t,
|
||||||
|
self.selected_envelope(|r| {
|
||||||
|
(r.hashrate_target_min_ths, r.hashrate_target_max_ths)
|
||||||
|
})
|
||||||
|
.0,
|
||||||
|
) =>
|
||||||
|
{
|
||||||
|
Some(scan::ConfigAction::HashRateTarget(t))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
PromptKind::Tuning => match val.trim().parse::<u8>() {
|
PromptKind::Tuning => match val.trim().parse::<u8>() {
|
||||||
@@ -2228,7 +2329,8 @@ impl App {
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let hint = match self.action_kind {
|
let hint = match self.action_kind {
|
||||||
PromptKind::Power => "enter a positive number of watts",
|
PromptKind::Power => "enter a number of watts within the valid range",
|
||||||
|
PromptKind::HashRateTarget => "enter a hashrate in TH/s within the valid range",
|
||||||
PromptKind::Tuning => "enter a percent from 0 to 100",
|
PromptKind::Tuning => "enter a percent from 0 to 100",
|
||||||
PromptKind::Timezone => "enter a valid IANA zone, e.g. America/Edmonton",
|
PromptKind::Timezone => "enter a valid IANA zone, e.g. America/Edmonton",
|
||||||
PromptKind::Password => "enter a non-empty password",
|
PromptKind::Password => "enter a non-empty password",
|
||||||
@@ -2620,6 +2722,9 @@ impl App {
|
|||||||
pub fn drain_scan(&mut self) {
|
pub fn drain_scan(&mut self) {
|
||||||
let Some(handle) = &self.scan else { return };
|
let Some(handle) = &self.scan else { return };
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
// Coalesce progress: a fast drain may pull many per-address updates; apply
|
||||||
|
// only the latest to the gauge/status once, after the loop.
|
||||||
|
let mut latest_progress: Option<(usize, usize, String)> = None;
|
||||||
loop {
|
loop {
|
||||||
match handle.rx.try_recv() {
|
match handle.rx.try_recv() {
|
||||||
Ok(ScanMsg::Started { total, targets }) => {
|
Ok(ScanMsg::Started { total, targets }) => {
|
||||||
@@ -2643,12 +2748,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
Ok(ScanMsg::Progress { done, total, ip }) => {
|
Ok(ScanMsg::Progress { done, total, ip }) => {
|
||||||
self.scan_total = total;
|
self.scan_total = total;
|
||||||
self.progress.gauge_set_value(done.min(total) as i32);
|
latest_progress = Some((done, total, ip));
|
||||||
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
|
||||||
wx_rs::set_status_text(&format!(
|
|
||||||
"{done}/{total}{where_} ({} found)",
|
|
||||||
self.rows.len()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
Ok(ScanMsg::Row(row)) => {
|
Ok(ScanMsg::Row(row)) => {
|
||||||
// Ignore stray rows outside the current target set.
|
// Ignore stray rows outside the current target set.
|
||||||
@@ -2692,6 +2792,15 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Apply the coalesced progress once (only while still scanning -- a Done/
|
||||||
|
// Failed in this same drain already finalised the gauge).
|
||||||
|
if self.scanning {
|
||||||
|
if let Some((done, total, ip)) = latest_progress {
|
||||||
|
self.progress.gauge_set_value(done.min(total) as i32);
|
||||||
|
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
||||||
|
wx_rs::set_status_text(&format!("{done}/{total}{where_} ({} found)", self.rows.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
if changed {
|
if changed {
|
||||||
self.fill_rows();
|
self.fill_rows();
|
||||||
}
|
}
|
||||||
@@ -2705,6 +2814,13 @@ impl App {
|
|||||||
self.drain_refresh();
|
self.drain_refresh();
|
||||||
self.drain_access_probe();
|
self.drain_access_probe();
|
||||||
self.drain_restore();
|
self.drain_restore();
|
||||||
|
// The drains above run every fast tick (smooth scan progress); the
|
||||||
|
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
||||||
|
// per second.
|
||||||
|
self.tick_accum = self.tick_accum.wrapping_add(1);
|
||||||
|
if self.tick_accum % TICKS_PER_SEC != 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
||||||
// operation progress lives in the Health column, so operations no longer
|
// operation progress lives in the Health column, so operations no longer
|
||||||
// hold or overwrite this line -- only an active scan does.
|
// hold or overwrite this line -- only an active scan does.
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Reclaim disk from the local cargo build directory.
|
||||||
|
#
|
||||||
|
# The app and the miner_probe CLI ship as release builds, and the unit tests run
|
||||||
|
# under --release too (see the build notes), so the dev/debug profile tree, any
|
||||||
|
# cross-compile target trees, and the coverage tree are all disposable: they only
|
||||||
|
# ever reappear if something explicitly rebuilds them, and left alone they grow
|
||||||
|
# without bound (a stray `cargo check`/`cargo test` can push the debug tree past
|
||||||
|
# 30 GiB on its own). The release tree is kept warm so the next iteration is still
|
||||||
|
# incremental; only its throwaway bits are pruned.
|
||||||
|
#
|
||||||
|
# Run it right after a release push -- the pushed commit is what CI builds and
|
||||||
|
# ships, so the local intermediates are spare from that point. Safe to run any
|
||||||
|
# time; it never deletes the release build itself.
|
||||||
|
#
|
||||||
|
# Honours CARGO_TARGET_DIR (the build sets it to ~/.cache/alkane-tk-target).
|
||||||
|
set -uo pipefail
|
||||||
|
|
||||||
|
TARGET="${CARGO_TARGET_DIR:-$HOME/.cache/alkane-tk-target}"
|
||||||
|
if [ ! -d "$TARGET" ]; then
|
||||||
|
echo "clean-old-builds: no target dir at $TARGET (nothing to do)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
human() { du -sh "$1" 2>/dev/null | cut -f1; }
|
||||||
|
before=$(human "$TARGET")
|
||||||
|
|
||||||
|
# Disposable profile/aux trees -- regenerated on demand, never shipped.
|
||||||
|
rm -rf "$TARGET"/debug "$TARGET"/llvm-cov-target "$TARGET"/doc 2>/dev/null
|
||||||
|
|
||||||
|
# Cross-compile target trees (e.g. armv7-unknown-linux-musleabihf). Rust target
|
||||||
|
# triples all carry "-unknown-"; the host release/debug trees do not, so this
|
||||||
|
# never touches the warm release build.
|
||||||
|
for d in "$TARGET"/*-unknown-*; do
|
||||||
|
[ -d "$d" ] && rm -rf "$d"
|
||||||
|
done
|
||||||
|
|
||||||
|
# The incremental caches are rebuild accelerators, not build output -- dropping
|
||||||
|
# them costs one slightly-slower rebuild and can free a few GiB.
|
||||||
|
rm -rf "$TARGET"/release/incremental 2>/dev/null
|
||||||
|
|
||||||
|
# If cargo-sweep is installed, additionally drop release artifacts not touched in
|
||||||
|
# the last few days (old dependency versions left by past rebuilds), keeping the
|
||||||
|
# current build. Optional: install with `cargo install cargo-sweep`.
|
||||||
|
if command -v cargo-sweep >/dev/null 2>&1; then
|
||||||
|
cargo sweep --time 3 "$TARGET" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
after=$(human "$TARGET")
|
||||||
|
echo "clean-old-builds: $TARGET $before -> $after"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
Subject: [PATCH 0016] braiins v26_04: single-flight auth + defensive get_data timeout
|
||||||
|
|
||||||
|
Round 17 R4 support. Braiins get_data fans out to ~12 authenticated REST calls
|
||||||
|
concurrently. Two hardening changes so a Braiins miner survives a busy scan:
|
||||||
|
|
||||||
|
- ensure_authenticated single-flights the login. Previously all ~12 concurrent
|
||||||
|
commands could see no token and each POST /auth/login -- a thundering herd that
|
||||||
|
doubled the connection load. Now the write lock is held across the login with a
|
||||||
|
double-check, so exactly one call authenticates and the rest reuse the token.
|
||||||
|
- The per-call timeout goes 5s -> 15s as defensive headroom (a healthy miner still
|
||||||
|
answers well under a second) so a call queued behind a scan burst completes
|
||||||
|
instead of dropping miner/stats.
|
||||||
|
|
||||||
|
Neither is the primary fix for the fleet-scan value dropout -- that is the
|
||||||
|
app-side scan concurrency cap (scan::SCAN_CONCURRENCY_LIMIT = 128), which keeps
|
||||||
|
the identification burst from starving these calls. These are the belt to that
|
||||||
|
suspenders. Verified live: a 10.4.1.0/24 scan now populates both Braiins corpus
|
||||||
|
miners (.27, .83) fully (watts, best-share, fw/control-board) and misses no
|
||||||
|
responders.
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
index 3e06b682..ae433d98 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
||||||
|
client: OnceCell::new(),
|
||||||
|
ip,
|
||||||
|
port: 80,
|
||||||
|
- timeout: Duration::from_secs(5),
|
||||||
|
+ // Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
+ // concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
+ // headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
+ // scan burst still completes instead of dropping miner/stats
|
||||||
|
+ // (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
+ // is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
+ timeout: Duration::from_secs(15),
|
||||||
|
bearer_token: RwLock::new(None),
|
||||||
|
auth,
|
||||||
|
}
|
||||||
|
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
+ // without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
+ // thundering herd that doubles the connection load and races under a
|
||||||
|
+ // high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
+ // across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
+ let mut guard = self.bearer_token.write().await;
|
||||||
|
+ if guard.is_some() {
|
||||||
|
+ return Ok(());
|
||||||
|
+ }
|
||||||
|
let token = match &self.auth {
|
||||||
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
|
MinerAuth::UserAndPass(creds) => {
|
||||||
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
- *self.bearer_token.write().await = Some(token);
|
||||||
|
+ *guard = Some(token);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
Subject: [PATCH 0017] luxminer v1: select power-limit profile by name, not step
|
||||||
|
|
||||||
|
Round 17 C (found via live tuning verification). set_power_limit mapped a watts
|
||||||
|
target to a LuxOS profile and applied it with `profileset`, but keyed on the
|
||||||
|
profile's `Step` field. The top/factory profile is named "default" and its Step
|
||||||
|
is "0"; LuxOS's profileset reads the parameter "0" as empty and answers
|
||||||
|
"Missing profile parameter" (Code 400). So the setter could never select the
|
||||||
|
default profile -- and a miner nudged off default by a watts limit could not be
|
||||||
|
returned to it via the power-limit control, stranding it below its factory point.
|
||||||
|
|
||||||
|
parse_profile_watts now keys on `Profile Name` (e.g. "480MHz", "default"), which
|
||||||
|
profileset accepts for every profile including the default. Verified live on a
|
||||||
|
LuxOS S19j Pro (10.4.1.60): set_power_limit(2700) -> 480MHz/2632W, and
|
||||||
|
set_power_limit(2900) -> default/2794W (previously errored), restoring the miner
|
||||||
|
to its factory profile. Unit test updated to key on names and to cover the
|
||||||
|
top-profile-is-"default" case.
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs b/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
||||||
|
index 2d1331bf..a4db1e03 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-luxminer/src/backends/v1/mod.rs
|
||||||
|
@@ -1078,8 +1078,14 @@ impl SetFaultLight for LuxMinerV1 {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-/// Parse a LuxOS `profiles` RPC reply into (step name, watts) pairs, keeping only
|
||||||
|
-/// profiles that report both a `Step` and a `Watts` value.
|
||||||
|
+/// Parse a LuxOS `profiles` RPC reply into (profile name, watts) pairs, keeping
|
||||||
|
+/// only profiles that report both a `Profile Name` and a `Watts` value.
|
||||||
|
+///
|
||||||
|
+/// The identifier is the `Profile Name` (e.g. "480MHz", "default"), NOT the
|
||||||
|
+/// `Step`: `profileset` takes the name, and the default profile's step is "0",
|
||||||
|
+/// which LuxOS reads as an empty parameter ("Missing profile parameter"), so a
|
||||||
|
+/// step-keyed setter can never select the default profile and could strand a
|
||||||
|
+/// miner off its factory point.
|
||||||
|
fn parse_profile_watts(profiles: &Value) -> Vec<(String, f64)> {
|
||||||
|
profiles
|
||||||
|
.get("PROFILES")
|
||||||
|
@@ -1087,16 +1093,16 @@ fn parse_profile_watts(profiles: &Value) -> Vec<(String, f64)> {
|
||||||
|
.map(|arr| {
|
||||||
|
arr.iter()
|
||||||
|
.filter_map(|p| {
|
||||||
|
- let step = p.get("Step").and_then(Value::as_str)?.to_string();
|
||||||
|
+ let name = p.get("Profile Name").and_then(Value::as_str)?.to_string();
|
||||||
|
let watts = p.get("Watts").and_then(Value::as_f64)?;
|
||||||
|
- Some((step, watts))
|
||||||
|
+ Some((name, watts))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
-/// Choose the LuxOS profile step to satisfy a watts power limit: the highest-watt
|
||||||
|
+/// Choose the LuxOS profile name to satisfy a watts power limit: the highest-watt
|
||||||
|
/// profile that does not exceed `target_w`, or -- when the target is below every
|
||||||
|
/// profile -- the lowest-watt profile. Returns None only when there are no
|
||||||
|
/// profiles to choose from.
|
||||||
|
@@ -1315,32 +1321,34 @@ mod tests {
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn power_limit_profile_selection() {
|
||||||
|
- // LuxOS reports a ladder of profiles, each with a Step name and Watts.
|
||||||
|
+ // LuxOS reports a ladder of profiles, each with a Profile Name and Watts.
|
||||||
|
+ // The top profile is named "default" (its Step is "0", which profileset
|
||||||
|
+ // rejects -- so selection must key on the name, not the step).
|
||||||
|
let steps = vec![
|
||||||
|
- ("-16".to_string(), 865.0),
|
||||||
|
- ("-4".to_string(), 2385.0),
|
||||||
|
- ("-2".to_string(), 2790.0),
|
||||||
|
- ("0".to_string(), 3100.0),
|
||||||
|
+ ("190MHz".to_string(), 865.0),
|
||||||
|
+ ("405MHz".to_string(), 2385.0),
|
||||||
|
+ ("455MHz".to_string(), 2790.0),
|
||||||
|
+ ("default".to_string(), 3100.0),
|
||||||
|
];
|
||||||
|
// The highest profile at or below the requested watts limit.
|
||||||
|
assert_eq!(
|
||||||
|
select_profile_at_or_below(&steps, 2500.0).as_deref(),
|
||||||
|
- Some("-4")
|
||||||
|
+ Some("405MHz")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
select_profile_at_or_below(&steps, 2790.0).as_deref(),
|
||||||
|
- Some("-2")
|
||||||
|
+ Some("455MHz")
|
||||||
|
);
|
||||||
|
- // Above every profile -> the maximum profile (a limit can't exceed the
|
||||||
|
- // hardware's top profile).
|
||||||
|
+ // Above every profile -> the maximum profile, selected by NAME ("default")
|
||||||
|
+ // rather than its step "0" (which profileset would reject).
|
||||||
|
assert_eq!(
|
||||||
|
select_profile_at_or_below(&steps, 9000.0).as_deref(),
|
||||||
|
- Some("0")
|
||||||
|
+ Some("default")
|
||||||
|
);
|
||||||
|
// Below every profile -> the minimum profile.
|
||||||
|
assert_eq!(
|
||||||
|
select_profile_at_or_below(&steps, 100.0).as_deref(),
|
||||||
|
- Some("-16")
|
||||||
|
+ Some("190MHz")
|
||||||
|
);
|
||||||
|
// No profiles -> nothing to choose.
|
||||||
|
assert_eq!(select_profile_at_or_below(&[], 2500.0), None);
|
||||||
@@ -335,13 +335,26 @@ int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
|
|||||||
if (h < 8) h = 8;
|
if (h < 8) h = 8;
|
||||||
int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
||||||
if (w < 1) w = 1;
|
if (w < 1) w = 1;
|
||||||
const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, w, h);
|
// The Font Awesome fan glyph fills its square box more than the other health
|
||||||
|
// icons (brain/chip/bolt), so at the shared size it reads as oversized. Draw
|
||||||
|
// it a bit smaller, centred in its full-size slot, so the slot advance and the
|
||||||
|
// per-icon tooltip hit-test (both keyed to the full width) are unchanged
|
||||||
|
// (round 17 R1).
|
||||||
|
int dw = w, dh = h;
|
||||||
|
if (shape == SHAPE_FAN) {
|
||||||
|
dh = (int)(h * 0.80 + 0.5);
|
||||||
|
if (dh < 8) dh = 8;
|
||||||
|
dw = (sv->vbh > 0) ? (int)((double)dh * sv->vbw / sv->vbh + 0.5) : dh;
|
||||||
|
if (dw < 1) dw = 1;
|
||||||
|
}
|
||||||
|
const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, dw, dh);
|
||||||
if (bmp.IsOk()) {
|
if (bmp.IsOk()) {
|
||||||
if (health) {
|
if (health) {
|
||||||
// Left-align and advance by less than the icon width so adjacent health
|
// Left-align in the full slot (a shrunk fan is centred within it) and
|
||||||
// icons sit close together (the Font Awesome glyphs carry inner margin,
|
// advance by less than the full icon width so adjacent health icons sit
|
||||||
// so a small bounding-box overlap does not visually collide).
|
// close together (the Font Awesome glyphs carry inner margin, so a small
|
||||||
dc->DrawBitmap(bmp, x, cy - h / 2, true);
|
// bounding-box overlap does not visually collide).
|
||||||
|
dc->DrawBitmap(bmp, x + (w - dw) / 2, cy - dh / 2, true);
|
||||||
int adv = w - 3;
|
int adv = w - 3;
|
||||||
return adv < 1 ? 1 : adv;
|
return adv < 1 ? 1 : adv;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+17
-2
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
|||||||
client: OnceCell::new(),
|
client: OnceCell::new(),
|
||||||
ip,
|
ip,
|
||||||
port: 80,
|
port: 80,
|
||||||
timeout: Duration::from_secs(5),
|
// Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
// concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
// headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
// scan burst still completes instead of dropping miner/stats
|
||||||
|
// (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
// is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
timeout: Duration::from_secs(15),
|
||||||
bearer_token: RwLock::new(None),
|
bearer_token: RwLock::new(None),
|
||||||
auth,
|
auth,
|
||||||
}
|
}
|
||||||
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
// without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
// thundering herd that doubles the connection load and races under a
|
||||||
|
// high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
// across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
let mut guard = self.bearer_token.write().await;
|
||||||
|
if guard.is_some() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let token = match &self.auth {
|
let token = match &self.auth {
|
||||||
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
MinerAuth::UserAndPass(creds) => {
|
MinerAuth::UserAndPass(creds) => {
|
||||||
self.authenticate(creds.password.expose_secret()).await?
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*self.bearer_token.write().await = Some(token);
|
*guard = Some(token);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"fe8effe2bfdda5d4c390656c016729f531a2b1c60033228557659c0befdde9f2","Cargo.lock":"a2b2cb45bb8b574e4f29ffdcdb5ebafd1dd87a0e6e11b47383973a99be367784","Cargo.toml":"503efa00123f8567f5fe40bf6a93e9e453d13094df0e0e1b7e98bdacdfbd2595","Cargo.toml.orig":"1c4ba0315fb491c086fc22a5c9bafaf7288c6b1fd48679c3d03dbd9df156a8b5","src/backends/mod.rs":"548d988b877410e330a55e275f64b2adad95ca5f1a0f085fe144957c96b8906f","src/backends/v1/mod.rs":"3e57d2c72d1d48c0b86f5438202633fcd9c1ebf375bd87ffe53ea5298ae936ad","src/backends/v1/rpc.rs":"25b0b9d56fbf113d5b8c3d3bc8eb7a0d67967b1f90f6d855da0b9f6ff24ae335","src/firmware.rs":"d95345295ae5043dfc357e69ae56c564b261fdb3b19b5c0ad1765267ff05ab3f","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"24191681066d5cf6a3022ad59c1baa92b57e3ce7717bb78d6a682af9e19a38c4","src/test/json/v1/config.json":"6ca9e6217d853d4bf1e75d69159630e9c9184ede96751706b88dfb699b5d59ad","src/test/json/v1/devs.json":"8f746dc6a02953eee5ee96dcf53be8dc7880a8ffc2c6e303f0284bcf6a97f42d","src/test/json/v1/events.json":"913683ff97af3333018807e1cc6e43467ea8a55925e5964dc402616615e2a5e3","src/test/json/v1/fans.json":"f8a9a1234d651055c80f4ebb1380bbb4e6d19eb33012902c55fff1385e592447","src/test/json/v1/healthchipget_0.json":"10619460049333ca016b2beec59ecc514ed9077fb19bdf7d0ed697201f8cb96c","src/test/json/v1/healthchipget_1.json":"80927fb1480c95be7f3a4e155d63f68f97720530ff7cf5d5ade06f2a3e810bf0","src/test/json/v1/healthchipget_2.json":"1e93ee2ab472ee7af58add08b4251e3ce0ad4f986d4325abbf43fd4c9b3dd28f","src/test/json/v1/mod.rs":"5a050f07455e622e35ad79ab1c8a6daf2ea38c4198472e49c6bbfe80538a9e48","src/test/json/v1/pools.json":"0068745327e31853fec051172abb7337f18a4cf9972c51967113d63f4f31f504","src/test/json/v1/power.json":"80534bb4581de7c8b747bf33b5d629b909c6e16a531d18ecb4afd7ffad3f014f","src/test/json/v1/profiles.json":"1f00429036e270daa08f12cd2d7357135070c57acd7a899a3c0af6167fe82abb","src/test/json/v1/stats.json":"2b105f0eb927046c9d2389bde978a43e3d54d12a420dfbe400786bb2f0ae31ca","src/test/json/v1/summary.json":"aaea3378eb7040952037e2f1ef7bd5f20a1b242bf93d4ba0501c46104b0b31a0","src/test/json/v1/temps.json":"1ee781cd2be3ed6a6a07e23be930248735fb51348c160453ba10f6ef71fcb7f1","src/test/json/v1/version.json":"4beb6ca5c0ebf359cee0434fdcc4d0a1a0607436634e46be3fd951e2256595df","src/test/json/v1/voltageget_0.json":"c445fa8674c2542b2d296fbafdd3166c53008dfbd9da8095327217989d37f1da","src/test/json/v1/voltageget_1.json":"96b91c3447dd66e7f1f575ed3b99611062e8b1d516d31422b74e425c46b2f49c","src/test/json/v1/voltageget_2.json":"7d40544021b2e32401135ae333067b770d2d736ada9e60deaca8fd8f5a79a1e3","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"513792d93a2a21d5258d9e6ac0e6dc9e0a6365118934514b4e656792add78066"}
|
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"fe8effe2bfdda5d4c390656c016729f531a2b1c60033228557659c0befdde9f2","Cargo.lock":"a2b2cb45bb8b574e4f29ffdcdb5ebafd1dd87a0e6e11b47383973a99be367784","Cargo.toml":"503efa00123f8567f5fe40bf6a93e9e453d13094df0e0e1b7e98bdacdfbd2595","Cargo.toml.orig":"1c4ba0315fb491c086fc22a5c9bafaf7288c6b1fd48679c3d03dbd9df156a8b5","src/backends/mod.rs":"548d988b877410e330a55e275f64b2adad95ca5f1a0f085fe144957c96b8906f","src/backends/v1/mod.rs":"0c12f7714b8486372054261afd263b61f432a446cef8ae9e6cd72550a0cf4f8f","src/backends/v1/rpc.rs":"25b0b9d56fbf113d5b8c3d3bc8eb7a0d67967b1f90f6d855da0b9f6ff24ae335","src/firmware.rs":"d95345295ae5043dfc357e69ae56c564b261fdb3b19b5c0ad1765267ff05ab3f","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"24191681066d5cf6a3022ad59c1baa92b57e3ce7717bb78d6a682af9e19a38c4","src/test/json/v1/config.json":"6ca9e6217d853d4bf1e75d69159630e9c9184ede96751706b88dfb699b5d59ad","src/test/json/v1/devs.json":"8f746dc6a02953eee5ee96dcf53be8dc7880a8ffc2c6e303f0284bcf6a97f42d","src/test/json/v1/events.json":"913683ff97af3333018807e1cc6e43467ea8a55925e5964dc402616615e2a5e3","src/test/json/v1/fans.json":"f8a9a1234d651055c80f4ebb1380bbb4e6d19eb33012902c55fff1385e592447","src/test/json/v1/healthchipget_0.json":"10619460049333ca016b2beec59ecc514ed9077fb19bdf7d0ed697201f8cb96c","src/test/json/v1/healthchipget_1.json":"80927fb1480c95be7f3a4e155d63f68f97720530ff7cf5d5ade06f2a3e810bf0","src/test/json/v1/healthchipget_2.json":"1e93ee2ab472ee7af58add08b4251e3ce0ad4f986d4325abbf43fd4c9b3dd28f","src/test/json/v1/mod.rs":"5a050f07455e622e35ad79ab1c8a6daf2ea38c4198472e49c6bbfe80538a9e48","src/test/json/v1/pools.json":"0068745327e31853fec051172abb7337f18a4cf9972c51967113d63f4f31f504","src/test/json/v1/power.json":"80534bb4581de7c8b747bf33b5d629b909c6e16a531d18ecb4afd7ffad3f014f","src/test/json/v1/profiles.json":"1f00429036e270daa08f12cd2d7357135070c57acd7a899a3c0af6167fe82abb","src/test/json/v1/stats.json":"2b105f0eb927046c9d2389bde978a43e3d54d12a420dfbe400786bb2f0ae31ca","src/test/json/v1/summary.json":"aaea3378eb7040952037e2f1ef7bd5f20a1b242bf93d4ba0501c46104b0b31a0","src/test/json/v1/temps.json":"1ee781cd2be3ed6a6a07e23be930248735fb51348c160453ba10f6ef71fcb7f1","src/test/json/v1/version.json":"4beb6ca5c0ebf359cee0434fdcc4d0a1a0607436634e46be3fd951e2256595df","src/test/json/v1/voltageget_0.json":"c445fa8674c2542b2d296fbafdd3166c53008dfbd9da8095327217989d37f1da","src/test/json/v1/voltageget_1.json":"96b91c3447dd66e7f1f575ed3b99611062e8b1d516d31422b74e425c46b2f49c","src/test/json/v1/voltageget_2.json":"7d40544021b2e32401135ae333067b770d2d736ada9e60deaca8fd8f5a79a1e3","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"513792d93a2a21d5258d9e6ac0e6dc9e0a6365118934514b4e656792add78066"}
|
||||||
+24
-16
@@ -1078,8 +1078,14 @@ impl SetFaultLight for LuxMinerV1 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse a LuxOS `profiles` RPC reply into (step name, watts) pairs, keeping only
|
/// Parse a LuxOS `profiles` RPC reply into (profile name, watts) pairs, keeping
|
||||||
/// profiles that report both a `Step` and a `Watts` value.
|
/// only profiles that report both a `Profile Name` and a `Watts` value.
|
||||||
|
///
|
||||||
|
/// The identifier is the `Profile Name` (e.g. "480MHz", "default"), NOT the
|
||||||
|
/// `Step`: `profileset` takes the name, and the default profile's step is "0",
|
||||||
|
/// which LuxOS reads as an empty parameter ("Missing profile parameter"), so a
|
||||||
|
/// step-keyed setter can never select the default profile and could strand a
|
||||||
|
/// miner off its factory point.
|
||||||
fn parse_profile_watts(profiles: &Value) -> Vec<(String, f64)> {
|
fn parse_profile_watts(profiles: &Value) -> Vec<(String, f64)> {
|
||||||
profiles
|
profiles
|
||||||
.get("PROFILES")
|
.get("PROFILES")
|
||||||
@@ -1087,16 +1093,16 @@ fn parse_profile_watts(profiles: &Value) -> Vec<(String, f64)> {
|
|||||||
.map(|arr| {
|
.map(|arr| {
|
||||||
arr.iter()
|
arr.iter()
|
||||||
.filter_map(|p| {
|
.filter_map(|p| {
|
||||||
let step = p.get("Step").and_then(Value::as_str)?.to_string();
|
let name = p.get("Profile Name").and_then(Value::as_str)?.to_string();
|
||||||
let watts = p.get("Watts").and_then(Value::as_f64)?;
|
let watts = p.get("Watts").and_then(Value::as_f64)?;
|
||||||
Some((step, watts))
|
Some((name, watts))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Choose the LuxOS profile step to satisfy a watts power limit: the highest-watt
|
/// Choose the LuxOS profile name to satisfy a watts power limit: the highest-watt
|
||||||
/// profile that does not exceed `target_w`, or -- when the target is below every
|
/// profile that does not exceed `target_w`, or -- when the target is below every
|
||||||
/// profile -- the lowest-watt profile. Returns None only when there are no
|
/// profile -- the lowest-watt profile. Returns None only when there are no
|
||||||
/// profiles to choose from.
|
/// profiles to choose from.
|
||||||
@@ -1315,32 +1321,34 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn power_limit_profile_selection() {
|
fn power_limit_profile_selection() {
|
||||||
// LuxOS reports a ladder of profiles, each with a Step name and Watts.
|
// LuxOS reports a ladder of profiles, each with a Profile Name and Watts.
|
||||||
|
// The top profile is named "default" (its Step is "0", which profileset
|
||||||
|
// rejects -- so selection must key on the name, not the step).
|
||||||
let steps = vec![
|
let steps = vec![
|
||||||
("-16".to_string(), 865.0),
|
("190MHz".to_string(), 865.0),
|
||||||
("-4".to_string(), 2385.0),
|
("405MHz".to_string(), 2385.0),
|
||||||
("-2".to_string(), 2790.0),
|
("455MHz".to_string(), 2790.0),
|
||||||
("0".to_string(), 3100.0),
|
("default".to_string(), 3100.0),
|
||||||
];
|
];
|
||||||
// The highest profile at or below the requested watts limit.
|
// The highest profile at or below the requested watts limit.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
select_profile_at_or_below(&steps, 2500.0).as_deref(),
|
select_profile_at_or_below(&steps, 2500.0).as_deref(),
|
||||||
Some("-4")
|
Some("405MHz")
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
select_profile_at_or_below(&steps, 2790.0).as_deref(),
|
select_profile_at_or_below(&steps, 2790.0).as_deref(),
|
||||||
Some("-2")
|
Some("455MHz")
|
||||||
);
|
);
|
||||||
// Above every profile -> the maximum profile (a limit can't exceed the
|
// Above every profile -> the maximum profile, selected by NAME ("default")
|
||||||
// hardware's top profile).
|
// rather than its step "0" (which profileset would reject).
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
select_profile_at_or_below(&steps, 9000.0).as_deref(),
|
select_profile_at_or_below(&steps, 9000.0).as_deref(),
|
||||||
Some("0")
|
Some("default")
|
||||||
);
|
);
|
||||||
// Below every profile -> the minimum profile.
|
// Below every profile -> the minimum profile.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
select_profile_at_or_below(&steps, 100.0).as_deref(),
|
select_profile_at_or_below(&steps, 100.0).as_deref(),
|
||||||
Some("-16")
|
Some("190MHz")
|
||||||
);
|
);
|
||||||
// No profiles -> nothing to choose.
|
// No profiles -> nothing to choose.
|
||||||
assert_eq!(select_profile_at_or_below(&[], 2500.0), None);
|
assert_eq!(select_profile_at_or_below(&[], 2500.0), None);
|
||||||
|
|||||||
Reference in New Issue
Block a user