From 19e469ebc416b0d50e9334c2ca3cc5918379d2a0 Mon Sep 17 00:00:00 2001 From: noah Date: Tue, 22 Sep 2026 18:01:49 -0600 Subject: [PATCH] item 12: clippy-clean our crate + add LICENSE files Cleared all clippy findings in alkane-gui (cargo clippy --no-deps): mechanical fixes via clippy --fix (redundant imports, useless format!, manual_contains, manual_is_multiple_of, unnecessary_map_or, unused parens) plus manual fixes: - type_complexity: factored the segment tuple into model::{Rgb, Segment} aliases. - large_enum_variant: #[allow] on ScanMsg/RefreshMsg with a note -- Row is the common variant, so boxing it to shrink the rare Started/Done would add an allocation per miner on the hot path. - dead code: removed unused SHAPE_PULSE_DOT, ColorKind::Accent, clear_op_status, and RestoreMsg's unread `total`; kept the restore/access-probe cancel handles (workers honour cancellation; UI stop control pending) under #[allow]. - question_mark, needless_range_loop, drop_non_drop, doc_lazy_continuation fixes. Only vendored wx-rs warnings remain (out of scope). Added LICENSE-MIT and LICENSE-APACHE (Cargo.toml already declares MIT OR Apache-2.0). 94 tests + selftest green. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6 --- LICENSE-APACHE | 201 +++++++++++++++++++++++ LICENSE-MIT | 21 +++ crates/alkane-gui/src/access_probe.rs | 2 +- crates/alkane-gui/src/bin/miner_probe.rs | 2 +- crates/alkane-gui/src/main.rs | 1 - crates/alkane-gui/src/model.rs | 9 +- crates/alkane-gui/src/naming.rs | 1 + crates/alkane-gui/src/pool_prefs.rs | 2 +- crates/alkane-gui/src/restore.rs | 19 ++- crates/alkane-gui/src/scan.rs | 22 ++- crates/alkane-gui/src/ui.rs | 50 +++--- 11 files changed, 282 insertions(+), 48 deletions(-) create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..17cd4bb4 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but not + limited to compiled object code, generated documentation, and + conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative + Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and do + not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an + addendum to the NOTICE text from the Work, provided that such + additional attribution notices cannot be construed as modifying + the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 Blueflare + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..ddf2c369 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Blueflare + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/alkane-gui/src/access_probe.rs b/crates/alkane-gui/src/access_probe.rs index 4919eeb8..99ea98a2 100644 --- a/crates/alkane-gui/src/access_probe.rs +++ b/crates/alkane-gui/src/access_probe.rs @@ -215,7 +215,7 @@ fn probe_whatsminer_access(ip: &str, passwords: &[String]) -> Option { Ok(v) => v, Err(_) => return None, }; - let Some(msg) = v.get("Msg") else { return None }; + let msg = v.get("Msg")?; let (Some(salt), Some(newsalt), Some(time)) = ( msg.get("salt").and_then(|s| s.as_str()), msg.get("newsalt").and_then(|s| s.as_str()), diff --git a/crates/alkane-gui/src/bin/miner_probe.rs b/crates/alkane-gui/src/bin/miner_probe.rs index 69bc6640..bc1dbdcc 100644 --- a/crates/alkane-gui/src/bin/miner_probe.rs +++ b/crates/alkane-gui/src/bin/miner_probe.rs @@ -1,6 +1,6 @@ //! miner_probe -- a read-only (by default) asic-rs diagnostic for live-hardware //! verification of the round-9 power-limit work. It reuses the same MinerFactory -//! + saved-credential setup the GUI uses (see crate::credentials), but as a +//! and saved-credential setup the GUI uses (see crate::credentials), but as a //! standalone CLI so hardware checks don't go through the wx event loop. //! //! Usage: diff --git a/crates/alkane-gui/src/main.rs b/crates/alkane-gui/src/main.rs index fd26d838..7236aca9 100644 --- a/crates/alkane-gui/src/main.rs +++ b/crates/alkane-gui/src/main.rs @@ -16,7 +16,6 @@ mod restore; mod scan; mod ui; -use wx_rs; fn main() { // Headless workflow self-test: render the bench-fleet fixtures through the diff --git a/crates/alkane-gui/src/model.rs b/crates/alkane-gui/src/model.rs index 9333235d..3bb96e61 100644 --- a/crates/alkane-gui/src/model.rs +++ b/crates/alkane-gui/src/model.rs @@ -123,12 +123,19 @@ fn combined_count(actual: Option, expected: Option) -> String { } } +/// An RGB colour (0-255 per channel) for a coloured text segment. +pub type Rgb = (u8, u8, u8); +/// One coloured text segment: an optional colour plus its text. Cells with +/// two-tone / multi-tone content (actual vs expected, per-fan colours) are built +/// as a `Vec` and encoded via [`encode_segments`]. +pub type Segment = (Option, String); + /// Encode colored text segments for a custom-rendered cell (see the wx-rs /// `SegmentRenderer`): segments are joined by U+001F, and within a segment an /// optional uppercase RRGGBB color is separated from its text by U+001E. /// `decode_segments_plain` is the inverse for anything that just wants the /// plain text (filtering, sorting, tests). -pub fn encode_segments(segs: &[(Option<(u8, u8, u8)>, String)]) -> String { +pub fn encode_segments(segs: &[Segment]) -> String { segs.iter() .map(|(color, text)| { let hex = color.map(|(r, g, b)| format!("{r:02X}{g:02X}{b:02X}")).unwrap_or_default(); diff --git a/crates/alkane-gui/src/naming.rs b/crates/alkane-gui/src/naming.rs index 5c13a6f2..a9ece6e3 100644 --- a/crates/alkane-gui/src/naming.rs +++ b/crates/alkane-gui/src/naming.rs @@ -200,6 +200,7 @@ fn compact_upper(s: &str) -> String { /// model era/class (best-effort, since the network data can't distinguish them): /// - Xilinx: S17/T17-era -> C49, otherwise (S19-era) -> C55. /// - AMLogic: XP-class / S19k (140mm fans) -> CBE, otherwise (120mm) -> C76. +/// /// `clean_model` is the already-cleaned model name (used for the era/class test). pub fn control_board_code(make: &str, board_name: &str, clean_model: &str) -> String { let (cpu, code) = control_board_split(make, board_name, clean_model); diff --git a/crates/alkane-gui/src/pool_prefs.rs b/crates/alkane-gui/src/pool_prefs.rs index 623f726b..29c1550d 100644 --- a/crates/alkane-gui/src/pool_prefs.rs +++ b/crates/alkane-gui/src/pool_prefs.rs @@ -92,7 +92,7 @@ fn dedupe_saved(presets: &[&str], values: &[String]) -> Vec { let mut out: Vec = Vec::new(); for v in values { let v = v.trim(); - if v.is_empty() || presets.iter().any(|p| *p == v) || out.iter().any(|s| s == v) { + if v.is_empty() || presets.contains(&v) || out.iter().any(|s| s == v) { continue; } out.push(v.to_string()); diff --git a/crates/alkane-gui/src/restore.rs b/crates/alkane-gui/src/restore.rs index 12e92c84..a30efa0d 100644 --- a/crates/alkane-gui/src/restore.rs +++ b/crates/alkane-gui/src/restore.rs @@ -4,7 +4,7 @@ //! (the stock image is retained on-device at install time; no image is uploaded): //! - VNish: POST /api/v1/unlock -> bearer -> POST /api/v1/firmware/remove //! - LuxOS: luxminer :4028 {"command":"logon"} -> SessionID -> -//! {"command":"uninstallluxos","parameter":""} +//! {"command":"uninstallluxos","parameter":""} //! - Braiins: SSH `uninstall.sh` (re-flashes the on-NAND stock backup) //! //! DESTRUCTIVE: this removes the running aftermarket firmware and reboots the @@ -24,17 +24,21 @@ use std::time::Duration; use crate::scan::fake_scan_enabled; pub enum RestoreMsg { - Started { total: usize }, + Started, Result { ip: String, ok: bool, detail: String }, - Done { total: usize }, + Done, } pub struct RestoreHandle { pub rx: Receiver, + // The worker honours cancellation between miners (see `tc` below); a UI stop + // control is not wired yet, so the handle-side trigger is kept for when it is. + #[allow(dead_code)] cancel: Arc, } impl RestoreHandle { + #[allow(dead_code)] pub fn stop(&self) { self.cancel.store(true, Ordering::Relaxed); } @@ -57,11 +61,10 @@ pub fn start_restore( ) -> RestoreHandle { let (tx, rx) = channel(); let cancel = Arc::new(AtomicBool::new(false)); - let total = targets.len(); if fake_scan_enabled() { // Offline demo: report each target as restored without touching anything. - let _ = tx.send(RestoreMsg::Started { total }); + let _ = tx.send(RestoreMsg::Started); for t in targets { let _ = tx.send(RestoreMsg::Result { ip: t.ip, @@ -69,7 +72,7 @@ pub fn start_restore( detail: "restored to stock (demo)".into(), }); } - let _ = tx.send(RestoreMsg::Done { total }); + let _ = tx.send(RestoreMsg::Done); return RestoreHandle { rx, cancel }; } @@ -77,7 +80,7 @@ pub fn start_restore( let _ = std::thread::Builder::new() .name("restore-stock".into()) .spawn(move || { - let _ = tx.send(RestoreMsg::Started { total }); + let _ = tx.send(RestoreMsg::Started); for t in targets { if tc.load(Ordering::Relaxed) { break; @@ -87,7 +90,7 @@ pub fn start_restore( return; } } - let _ = tx.send(RestoreMsg::Done { total }); + let _ = tx.send(RestoreMsg::Done); }); RestoreHandle { rx, cancel } } diff --git a/crates/alkane-gui/src/scan.rs b/crates/alkane-gui/src/scan.rs index 21a01bd5..ce76c44c 100644 --- a/crates/alkane-gui/src/scan.rs +++ b/crates/alkane-gui/src/scan.rs @@ -13,6 +13,11 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{channel, Receiver}; use std::sync::Arc; +// `Row` is the common variant (one per miner) while `Started`/`Done` are sent +// once each, so boxing the large row to shrink the rare variants would add an +// allocation on the hot path for no real gain -- the message is moved straight +// through an mpsc channel and dropped. +#[allow(clippy::large_enum_variant)] pub enum ScanMsg { /// A new scan started: `total` addresses to probe, and the exact set of /// target IPs (as strings) so the UI can drop miners no longer in range. @@ -156,7 +161,7 @@ pub fn parse_line(line: &str) -> Result, String> { if parts.len() == 4 && parts.iter().all(|p| is_octet_spec(p)) { let r: Vec<(u8, u8)> = parts.iter().map(|p| parse_octet_spec(p)).collect::>()?; - let count: u64 = r.iter().map(|(lo, hi)| (*hi as u64 - *lo as u64 + 1)).product(); + let count: u64 = r.iter().map(|(lo, hi)| *hi as u64 - *lo as u64 + 1).product(); if count > MAX_ADDRS { return Err(format!("range too large (> {MAX_ADDRS} addresses): {line}")); } @@ -427,7 +432,7 @@ pub fn start_scan(lines: Vec, timeout_secs: u64) -> ScanHandle { return; // UI gone } } - if done % step == 0 || done == total { + if done.is_multiple_of(step) || done == total { let _ = tx.send(ScanMsg::Progress { done, total, ip: ip.to_string() }); } } @@ -569,6 +574,7 @@ mod board_index_tests { /// generation (S21 family, T21), where Bitmain dropped the per-board PIC. /// - PIC: the rest of the S19 line (BM1362/BM1366, PIC16F1704/1542). /// - unknown: everything else (older Antminers, non-Antminer makes). +/// /// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC /// revisions exist); it is assumed PIC unless the model string says noPIC. fn infer_pic(model: &str) -> Option { @@ -1193,7 +1199,7 @@ pub fn start_config_action(ips: Vec, action: ConfigAction) -> ActionHand match outcome { Ok(true) => (true, "ok".to_string()), Ok(false) => (false, "refused".to_string()), - Err(e) => (false, format!("{e}")), + Err(e) => (false, e.to_string()), } } Ok(None) => (false, "no miner at IP".to_string()), @@ -1328,6 +1334,10 @@ pub fn start_pools_action(targets: Vec) -> ActionHandle { /// Progress/results from a background refresh of a specific, already-known /// set of miners (re-poll on a timer or after a right-click "Refresh" action, /// as opposed to `start_scan`'s full subnet sweep). +// `Row` is the common variant; boxing it to shrink the rare Started/Done/Failed +// variants would add an allocation per refreshed miner for no real gain (see the +// note on ScanMsg). +#[allow(clippy::large_enum_variant)] pub enum RefreshMsg { Started { total: usize }, /// A miner's telemetry was re-read successfully. @@ -1507,7 +1517,7 @@ pub fn start_firmware_flash_action(ips: Vec, image: FirmwareImage) -> Ac match flash_one(&*miner, &image).await { Ok(true) => (true, "ok".to_string()), Ok(false) => (false, "refused".to_string()), - Err(e) => (false, format!("{e}")), + Err(e) => (false, e.to_string()), } } } @@ -1543,10 +1553,14 @@ pub enum AccessProbeMsg { /// A running access probe; `stop` cancels the remaining miners. pub struct AccessProbeHandle { pub rx: Receiver, + // The worker honours cancellation between miners; a UI stop control is not + // wired yet, so the handle-side trigger is kept for when it is. + #[allow(dead_code)] cancel: Arc, } impl AccessProbeHandle { + #[allow(dead_code)] pub fn stop(&self) { self.cancel.store(true, Ordering::Relaxed); } diff --git a/crates/alkane-gui/src/ui.rs b/crates/alkane-gui/src/ui.rs index f09c28ce..22a467a5 100644 --- a/crates/alkane-gui/src/ui.rs +++ b/crates/alkane-gui/src/ui.rs @@ -286,7 +286,7 @@ fn encode_board_temps_cell(pal: &Palette, temps: &[f64], avg: f64) -> String { let plain = if avg > 0.0 { format!("{avg:.0}") } else { String::new() }; return encode_temp_cell(pal, &plain, avg); } - let mut segs: Vec<(Option<(u8, u8, u8)>, String)> = Vec::with_capacity(temps.len() * 2 - 1); + let mut segs: Vec = Vec::with_capacity(temps.len() * 2 - 1); for (i, &t) in temps.iter().enumerate() { if i > 0 { segs.push((None, " / ".to_string())); @@ -315,9 +315,6 @@ const SHAPE_HASHING: &str = "\u{0004}"; const SHAPE_SLOW: &str = "\u{0005}"; const SHAPE_NOTHASHING: &str = "\u{0006}"; const SHAPE_PAUSED: &str = "\u{0008}"; -/// Locate-light dot that fades in and out (round 12 #6); distinct from the static -/// `SHAPE_DOT` so only the flashing light pulses, not the hashboard health dots. -const SHAPE_PULSE_DOT: &str = "\u{000B}"; // Component-health icons (round 13 #3): one sentinel per component kind, each // drawn from the operator-supplied Font Awesome SVG and recoloured per component // state. Registered in `register_cell_icons`. @@ -379,7 +376,7 @@ fn encode_board_dots(pal: &Palette, status: &[crate::model::BoardHealth]) -> Str if status.is_empty() { return encode_segments(&[(None, String::new())]); } - let segs: Vec<(Option<(u8, u8, u8)>, String)> = status + let segs: Vec = status .iter() .rev() .map(|h| { @@ -455,7 +452,7 @@ fn encode_component_health( max_fans: usize, max_boards: usize, ) -> String { - let mut segs: Vec<(Option<(u8, u8, u8)>, String)> = Vec::new(); + let mut segs: Vec = Vec::new(); segs.push((Some(health_color(pal, r.power_health())), SHAPE_BOLT.to_string())); segs.push((Some(health_color(pal, r.control_health())), SHAPE_BRAIN.to_string())); let fans = r.fan_healths(); @@ -535,7 +532,7 @@ fn encode_cooling_cell(pal: &Palette, fans: &[f64]) -> String { if fans.is_empty() { return encode_segments(&[(None, String::new())]); } - let mut segs: Vec<(Option<(u8, u8, u8)>, String)> = Vec::with_capacity(fans.len() * 2 - 1); + let mut segs: Vec = Vec::with_capacity(fans.len() * 2 - 1); for (i, &rpm) in fans.iter().enumerate() { if i > 0 { segs.push((None, "/".to_string())); @@ -571,7 +568,6 @@ enum ColorKind { Green, Amber, Red, - Accent, Blue, } @@ -581,7 +577,6 @@ fn kind_color(pal: &Palette, k: ColorKind) -> (u8, u8, u8) { ColorKind::Green => pal.green, ColorKind::Amber => pal.amber, ColorKind::Red => pal.red, - ColorKind::Accent => pal.accent, ColorKind::Blue => pal.accent, } } @@ -880,7 +875,8 @@ pub fn build(frame: Widget) -> App { // (round 12 #1); it still dims with focus like the other neutral cards. let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Neutral, Some(SVG_HIVE)); let (card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT)); - drop(mk_card); + // (mk_card's borrow of kpi_cards ends here at its last use, freeing kpi_cards + // for the App below.) // The two wide cards carry a units-bearing value (icon + e.g. "685 TH" / // "21.3 kW"); give them a larger min width so the value never clips, and // collapse them before the row would squeeze them below it (round 12 #2). @@ -943,12 +939,12 @@ pub fn build(frame: Widget) -> App { l10n_labels.push((b, label)); b }; - let presets_btn = tbtn("Presets", ID_PRESETS); - let filter_btn = tbtn("Filter", ID_FILTER); - let columns_btn = tbtn("Columns", ID_COLUMNS); - let export_btn = tbtn("Export", ID_EXPORT); + let _presets_btn = tbtn("Presets", ID_PRESETS); + let _filter_btn = tbtn("Filter", ID_FILTER); + let _columns_btn = tbtn("Columns", ID_COLUMNS); + let _export_btn = tbtn("Export", ID_EXPORT); // The old Credentials button is now a Settings menu (round 15 #13). - let creds_btn = tbtn("Settings", ID_SETTINGS); + let _creds_btn = tbtn("Settings", ID_SETTINGS); root.add_sizer(ctl, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 4); // Track the KPI captions for live re-localization (index 5, the hashrate // caption, is dynamic per-algorithm so it is refreshed by refresh_kpis). @@ -1604,12 +1600,6 @@ impl App { self.fill_rows(); } - /// Clear one miner's in-flight operation label. Repaint is left to the caller - /// (usually a single fill_rows after draining a batch of results). - fn clear_op_status(&mut self, ip: &str) { - self.op_status.remove(ip); - } - /// Build (but do not show) the Configure-pools dialog (round 15 #1): three /// pool rows, each with address + account + worker + password boxes and a "+" /// dropdown next to each. Address/account are required per used row; the @@ -1654,9 +1644,9 @@ impl App { let lbl = Widget::static_text(dlg, &format!("Pool {}", row + 1)); lbl.set_min_size(46, -1); rsizer.add(lbl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6); - for field in 0..4usize { + for (field, &w) in widths.iter().enumerate() { let input = Widget::text_ctrl(dlg, false); - input.set_min_size(widths[field], -1); + input.set_min_size(w, -1); rsizer.add(input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6); let plus = Widget::button(dlg, "+", ID_POOL_PLUS_BASE + (row * 4 + field) as i32); plus.set_min_size(PLUS_W, -1); // wide enough that the "+" glyph isn't clipped @@ -2043,7 +2033,7 @@ impl App { let mut op_clear: Vec = Vec::new(); while let Ok(msg) = h.rx.try_recv() { match msg { - restore::RestoreMsg::Started { .. } => {} + restore::RestoreMsg::Started => {} restore::RestoreMsg::Result { ip, ok, detail } => { op_clear.push(ip.clone()); if ok { @@ -2052,7 +2042,7 @@ impl App { fails.push(format!("{ip}: {detail}")); } } - restore::RestoreMsg::Done { .. } => done = true, + restore::RestoreMsg::Done => done = true, } } for ip in &op_clear { @@ -2211,9 +2201,7 @@ impl App { // do inline here (unlike destroying a control) since // `dispatch` already tolerates re-entrant events via // try_borrow_mut while a nested loop is running. - let Some(path) = Widget::file_dialog(Widget::main_frame(), "Choose firmware image") else { - return None; - }; + let path = Widget::file_dialog(Widget::main_frame(), "Choose firmware image")?; match FirmwareImage::from_file(&path) { Ok(image) => return Some(self.build_flash_confirm_dialog(&path, targets, image)), Err(e) => wx_rs::set_status_text(&format!("failed to read firmware image: {e}")), @@ -2384,7 +2372,7 @@ impl App { // 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) + v > 0.0 && v.is_finite() && range.is_none_or(|(a, b)| v >= a && v <= b) }; let action = match self.action_kind { PromptKind::Power => match val.trim().parse::() { @@ -3007,7 +2995,7 @@ impl App { // 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 { + if !self.tick_accum.is_multiple_of(TICKS_PER_SEC) { return; } // The bottom-left status is for the scan only (round 15 #8): per-miner @@ -3165,7 +3153,7 @@ impl App { /// Apply a header-menu action to the remembered column. fn on_header_menu(&mut self, id: i32) -> Option { - let Some(col) = self.header_menu_col else { return None }; + let col = self.header_menu_col?; match id { ID_HDR_SORT_ASC => { self.view.sort = Some((col, true));