From ddec9fcb6da75a7b4949426cfcb3304794fd88be Mon Sep 17 00:00:00 2001 From: hinto-janaiyo Date: Fri, 16 Dec 2022 14:33:04 -0500 Subject: [PATCH] cargo check/clippy fixes --- Cargo.lock | 8 ++++---- README.md | 6 +++--- src/disk.rs | 6 +++--- src/helper.rs | 55 ++++++++++++++++++++++++++++++++++++++++++++++----- src/main.rs | 2 +- src/update.rs | 16 ++++----------- 6 files changed, 65 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9b5a54..ffbaa60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3411,18 +3411,18 @@ checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "serde" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" dependencies = [ "proc-macro2", "quote", diff --git a/README.md b/README.md index 6047403..54530ce 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ P2Pool Simple allows you to ping & connect to a [Community Monero Node](#communi To start P2Pool, first input the Monero address you'd like to receive payouts from. You must use a primary Monero address to mine on P2Pool (starts with a 4). It is highly recommended to create a new wallet since addresses are public on P2Pool! -**Be aware: [There are negative privacy implications when using Monero node not in your control.](https://www.getmonero.org/resources/moneropedia/remote-node.html)** Select a community node that you trust. If you'd like to manually specify a node to connect to, see [Advanced.](#advanced) +**Warning: [There are negative privacy and security implications when using Monero node not in your control.](https://www.getmonero.org/resources/moneropedia/remote-node.html)** Select a community node that you trust, or better yet, run your own node. If you'd like to manually specify a node to connect to, see [Advanced.](#advanced) --- @@ -285,7 +285,7 @@ In general: --- ### Swapping P2Pool/XMRig -If you downloaded Gupax standalone and want to use your own `P2Pool/XMRig` binaries and/or want to swap them, you can: +If you want to use your own `P2Pool/XMRig` binaries and/or want to swap them, you can: - Edit the PATH in `Gupax Advanced` to point at the new binaries - Change the binary itself @@ -403,7 +403,7 @@ The manual pool list allows you save and connect up-to 1000 custom Pools (regard |------------|---------------------------------------------------------------|--------------------------------------------------------|----------------| | `Name` | A unique name to identify this pool (only for Gupax purposes) | Only `[A-Za-z0-9-_.]` and spaces allowed | 30 characters | | `IP` | The pool IP to connect to with XMRig | It must be a valid IPv4 address or a valid domain name | 255 characters | -| `Port` | The port of pool | `[1-65535]` | 5 characters | +| `Port` | The port of the pool | `[1-65535]` | 5 characters | | `Rig` | An optional rig ID; This will be the name shown on the pool | Only `[A-Za-z0-9-_]` and spaces allowed | 30 characters | The HTTP API textboxes allow you to change to IP/Port XMRig's HTTP API opens up on: diff --git a/src/disk.rs b/src/disk.rs index be0c943..7f3ba4f 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -275,7 +275,7 @@ impl State { Ok(o) => o, Err(e) => { error!("State | Couldn't serialize default file: {}", e); return Err(TomlError::Serialize(e)) }, }; - fs::write(path, &string)?; + fs::write(path, string)?; info!("State | Write ... OK"); Ok(new) } @@ -400,7 +400,7 @@ impl Node { info!("Node | Creating new default..."); let new = Self::new_vec(); let string = Self::to_string(&Self::new_vec())?; - fs::write(path, &string)?; + fs::write(path, string)?; info!("Node | Write ... OK"); Ok(new) } @@ -503,7 +503,7 @@ impl Pool { info!("Pool | Creating new default..."); let new = Self::new_vec(); let string = Self::to_string(&Self::new_vec())?; - fs::write(path, &string)?; + fs::write(path, string)?; info!("Pool | Write ... OK"); Ok(new) } diff --git a/src/helper.rs b/src/helper.rs index 82b2e25..e3a087f 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -492,7 +492,16 @@ impl Helper { let uptime = HumanTime::into_human(start.elapsed()); info!("P2Pool Watchdog | Stopped ... Uptime was: [{}], Exit status: [{}]", uptime, exit_status); // This is written directly into the GUI, because sometimes the 900ms event loop can't catch it. - writeln!(gui_api.lock().unwrap().output, "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE); + if let Err(e) = writeln!( + gui_api.lock().unwrap().output, + "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", + HORI_CONSOLE, + uptime, + exit_status, + HORI_CONSOLE + ) { + error!("P2Pool Watchdog | GUI Uptime/Exit status write failed: {}", e); + } process.lock().unwrap().signal = ProcessSignal::None; debug!("P2Pool Watchdog | Secret dead process reap OK, breaking"); break @@ -517,7 +526,16 @@ impl Helper { let uptime = HumanTime::into_human(start.elapsed()); info!("P2Pool Watchdog | Stopped ... Uptime was: [{}], Exit status: [{}]", uptime, exit_status); // This is written directly into the GUI API, because sometimes the 900ms event loop can't catch it. - writeln!(gui_api.lock().unwrap().output, "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE); + if let Err(e) = writeln!( + gui_api.lock().unwrap().output, + "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", + HORI_CONSOLE, + uptime, + exit_status, + HORI_CONSOLE + ) { + error!("P2Pool Watchdog | GUI Uptime/Exit status write failed: {}", e); + } process.lock().unwrap().signal = ProcessSignal::None; debug!("P2Pool Watchdog | Stop SIGNAL done, breaking"); break @@ -534,7 +552,16 @@ impl Helper { let uptime = HumanTime::into_human(start.elapsed()); info!("P2Pool Watchdog | Stopped ... Uptime was: [{}], Exit status: [{}]", uptime, exit_status); // This is written directly into the GUI API, because sometimes the 900ms event loop can't catch it. - writeln!(gui_api.lock().unwrap().output, "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE); + if let Err(e) = writeln!( + gui_api.lock().unwrap().output, + "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", + HORI_CONSOLE, + uptime, + exit_status, + HORI_CONSOLE + ) { + error!("P2Pool Watchdog | GUI Uptime/Exit status write failed: {}", e); + } process.lock().unwrap().state = ProcessState::Waiting; debug!("P2Pool Watchdog | Restart SIGNAL done, breaking"); break @@ -831,7 +858,16 @@ impl Helper { }; let uptime = HumanTime::into_human(start.elapsed()); info!("XMRig | Stopped ... Uptime was: [{}], Exit status: [{}]", uptime, exit_status); - writeln!(gui_api.lock().unwrap().output, "{}\nXMRig stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE); + if let Err(e) = writeln!( + gui_api.lock().unwrap().output, + "{}\nXMRig stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", + HORI_CONSOLE, + uptime, + exit_status, + HORI_CONSOLE + ) { + error!("XMRig Watchdog | GUI Uptime/Exit status write failed: {}", e); + } process.lock().unwrap().signal = ProcessSignal::None; debug!("XMRig Watchdog | Secret dead process reap OK, breaking"); break @@ -872,7 +908,16 @@ impl Helper { }; let uptime = HumanTime::into_human(start.elapsed()); info!("XMRig | Stopped ... Uptime was: [{}], Exit status: [{}]", uptime, exit_status); - writeln!(gui_api.lock().unwrap().output, "{}\nXMRig stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE); + if let Err(e) = writeln!( + gui_api.lock().unwrap().output, + "{}\nXMRig stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n\n\n", + HORI_CONSOLE, + uptime, + exit_status, + HORI_CONSOLE + ) { + error!("XMRig Watchdog | GUI Uptime/Exit status write failed: {}", e); + } let mut process = process.lock().unwrap(); match process.signal { ProcessSignal::Stop => process.signal = ProcessSignal::None, diff --git a/src/main.rs b/src/main.rs index 3a64c6a..428913f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -150,7 +150,7 @@ pub struct App { impl App { fn cc(cc: &eframe::CreationContext<'_>, app: Self) -> Self { let resolution = cc.integration_info.window_info.size; - init_text_styles(&cc.egui_ctx, resolution[0] as f32); + init_text_styles(&cc.egui_ctx, resolution[0]); Self { resolution, ..app diff --git a/src/update.rs b/src/update.rs index f7a021f..f9cd7fd 100644 --- a/src/update.rs +++ b/src/update.rs @@ -172,33 +172,25 @@ const UPGRADE: &str = "----------------- Upgrade ------------------"; pub fn check_p2pool_path(path: &str) -> bool { let path = match crate::disk::into_absolute_path(path.to_string()) { Ok(p) => p, - Err(e) => return false, + Err(_) => return false, }; let path = match path.file_name() { Some(p) => p, None => { error!("Couldn't get P2Pool file name"); return false; }, }; - if path == ACCEPTABLE_P2POOL[0] || path == ACCEPTABLE_P2POOL[1] || path == ACCEPTABLE_P2POOL[2] || path == ACCEPTABLE_P2POOL[3] { - true - } else { - false - } + path == ACCEPTABLE_P2POOL[0] || path == ACCEPTABLE_P2POOL[1] || path == ACCEPTABLE_P2POOL[2] || path == ACCEPTABLE_P2POOL[3] } pub fn check_xmrig_path(path: &str) -> bool { let path = match crate::disk::into_absolute_path(path.to_string()) { Ok(p) => p, - Err(e) => return false, + Err(_) => return false, }; let path = match path.file_name() { Some(p) => p, None => { error!("Couldn't get XMRig file name"); return false; }, }; - if path == ACCEPTABLE_XMRIG[0] || path == ACCEPTABLE_XMRIG[1] || path == ACCEPTABLE_XMRIG[2] || path == ACCEPTABLE_XMRIG[3] { - true - } else { - false - } + path == ACCEPTABLE_XMRIG[0] || path == ACCEPTABLE_XMRIG[1] || path == ACCEPTABLE_XMRIG[2] || path == ACCEPTABLE_XMRIG[3] } //---------------------------------------------------------------------------------------------------- Update struct/impl