Status Submenu: fix some clippy warnings

This commit is contained in:
hinto-janaiyo 2023-01-01 18:57:11 -05:00
parent 830ee9ebcd
commit af688427c7
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
7 changed files with 25 additions and 43 deletions

4
Cargo.lock generated
View file

@ -2497,9 +2497,9 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom"
version = "7.1.1"
version = "7.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c"
dependencies = [
"memchr",
"minimal-lexical",

View file

@ -174,7 +174,6 @@ pub const STATUS_XMRIG_THREADS: &str = "The amount of threads XMRig is curre
// Status Submenus
pub const STATUS_SUBMENU_PROCESSES: &str = "View the status of process related data for [Gupax|P2Pool|XMRig]";
pub const STATUS_SUBMENU_P2POOL: &str = "View P2Pool specific data";
pub const STATUS_SUBMENU_MONERO: &str = "View general Monero blockchain data";
//-- P2Pool
pub const STATUS_SUBMENU_PAYOUT: &str = "The total amount of payouts received via P2Pool across all time. This includes all payouts you have ever received using Gupax and P2Pool.";
pub const STATUS_SUBMENU_XMR: &str = "The total of XMR mined via P2Pool across all time. This includes all the XMR you have ever mined using Gupax and P2Pool.";
@ -316,6 +315,7 @@ pub const XMRIG_NAME: &str = "Add a unique name to identify this pool;
pub const XMRIG_IP: &str = "Specify the pool IP to connect to with XMRig; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
pub const XMRIG_PORT: &str = "Specify the port of the pool; [1-65535]";
pub const XMRIG_RIG: &str = "Add an optional rig ID. This will be the name shown on the pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
#[cfg(not(target_os = "linux"))]
pub const XMRIG_PAUSE: &str = "THIS SETTING IS DISABLED IF SET TO [0]. Pause mining if user is active, resume after";
pub const XMRIG_API_IP: &str = "Specify which IP to bind to for XMRig's HTTP API; If empty: [localhost/127.0.0.1]";
pub const XMRIG_API_PORT: &str = "Specify which port to bind to for XMRig's HTTP API; If empty: [18088]";

View file

@ -48,7 +48,6 @@ use crate::{
Tab,
xmr::*,
macros::*,
P2poolRegex,
};
use log::*;
#[cfg(target_family = "unix")]
@ -167,7 +166,7 @@ pub fn create_gupax_dir(path: &PathBuf) -> Result<(), TomlError> {
Ok(_) => info!("OS | Create data path ... OK"),
Err(e) => { error!("OS | Create data path ... FAIL ... {}", e); return Err(TomlError::Io(e)) },
}
set_unix_750_perms(&path)
set_unix_750_perms(path)
}
pub fn create_gupax_p2pool_dir(path: &PathBuf) -> Result<(), TomlError> {
@ -199,13 +198,6 @@ pub fn print_dash(toml: &str) {
info!("{}", HORIZONTAL);
}
// Write str to console with [debug!] surrounded by "---"
pub fn print_dash_debug(toml: &str) {
info!("{}", HORIZONTAL);
for i in toml.lines() { debug!("{}", i); }
info!("{}", HORIZONTAL);
}
// Turn relative paths into absolute paths
pub fn into_absolute_path(path: String) -> Result<PathBuf, TomlError> {
let path = PathBuf::from(path);
@ -689,7 +681,7 @@ impl GupaxP2poolApi {
let mut log_rev = String::with_capacity(self.log.len());
for line in self.log.lines().rev() {
log_rev.push_str(line);
log_rev.push_str("\n");
log_rev.push('\n');
}
self.log_rev = log_rev;
}
@ -700,7 +692,7 @@ impl GupaxP2poolApi {
pub fn append_log(&mut self, formatted_log_line: &str) {
self.log.push_str(formatted_log_line);
self.log.push_str("\n");
self.log.push('\n');
}
pub fn append_head_log_rev(&mut self, formatted_log_line: &str) {
@ -836,7 +828,7 @@ impl Display for Submenu {
use Submenu::*;
match self {
P2pool => write!(f, "P2Pool"),
_ => write!(f, "{}", self),
_ => write!(f, "{:?}", self),
}
}
}
@ -865,7 +857,7 @@ impl Default for PayoutView {
impl Display for PayoutView {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self)
write!(f, "{:?}", self)
}
}
@ -935,8 +927,8 @@ impl Hash {
impl Display for Hash {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Hash::Hash => write!(f, "{}", self),
_ => write!(f, "{}hash", self),
Hash::Hash => write!(f, "Hash"),
_ => write!(f, "{:?}hash", self),
}
}
}

View file

@ -27,7 +27,6 @@ use egui::{
};
use crate::{
constants::*,
disk::Gupax,
update::*,
ErrorState,
Restart,

View file

@ -81,11 +81,7 @@ pub struct Helper {
pub img_xmrig: Arc<Mutex<ImgXmrig>>, // A static "image" of the data XMRig started with
pub_api_p2pool: Arc<Mutex<PubP2poolApi>>, // P2Pool API state (for Helper/P2Pool thread)
pub_api_xmrig: Arc<Mutex<PubXmrigApi>>, // XMRig API state (for Helper/XMRig thread)
pub gupax_p2pool_api: Arc<Mutex<GupaxP2poolApi>>, //
priv_api_p2pool_local: Arc<Mutex<PrivP2poolLocalApi>>, // Serde struct(s) for P2Pool's API files
priv_api_p2pool_network: Arc<Mutex<PrivP2poolNetworkApi>>,
priv_api_p2pool_pool: Arc<Mutex<PrivP2poolPoolApi>>,
priv_api_xmrig: Arc<Mutex<PrivXmrigApi>>, // Serde struct for XMRig's HTTP API
pub gupax_p2pool_api: Arc<Mutex<GupaxP2poolApi>>, //
}
// The communication between the data here and the GUI thread goes as follows:
@ -237,10 +233,6 @@ impl Helper {
instant,
pub_sys,
uptime: HumanTime::into_human(instant.elapsed()),
priv_api_p2pool_local: arc_mut!(PrivP2poolLocalApi::new()),
priv_api_p2pool_network: arc_mut!(PrivP2poolNetworkApi::new()),
priv_api_p2pool_pool: arc_mut!(PrivP2poolPoolApi::new()),
priv_api_xmrig: arc_mut!(PrivXmrigApi::new()),
pub_api_p2pool: arc_mut!(PubP2poolApi::new()),
pub_api_xmrig: arc_mut!(PubXmrigApi::new()),
// These are created when initializing [App], since it needs a handle to it as well
@ -254,7 +246,7 @@ impl Helper {
}
}
fn read_pty_xmrig(output_parse: Arc<Mutex<String>>, output_pub: Arc<Mutex<String>>, reader: Box<dyn std::io::Read + Send>) {
fn read_pty_xmrig(_output_parse: Arc<Mutex<String>>, output_pub: Arc<Mutex<String>>, reader: Box<dyn std::io::Read + Send>) {
use std::io::BufRead;
let mut stdout = std::io::BufReader::new(reader).lines();
// We don't need to write twice for XMRig, since we dont parse it... yet.
@ -740,10 +732,9 @@ impl Helper {
let process = Arc::clone(&lock!(helper).xmrig);
let gui_api = Arc::clone(&lock!(helper).gui_api_xmrig);
let pub_api = Arc::clone(&lock!(helper).pub_api_xmrig);
let priv_api = Arc::clone(&lock!(helper).priv_api_xmrig);
let path = path.clone();
thread::spawn(move || {
Self::spawn_xmrig_watchdog(process, gui_api, pub_api, priv_api, args, path, sudo, api_ip_port);
Self::spawn_xmrig_watchdog(process, gui_api, pub_api, args, path, sudo, api_ip_port);
});
}
@ -849,7 +840,7 @@ impl Helper {
// The XMRig watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
// This isn't actually async, a tokio runtime is unfortunately needed because [Hyper] is an async library (HTTP API calls)
#[tokio::main]
async fn spawn_xmrig_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubXmrigApi>>, pub_api: Arc<Mutex<PubXmrigApi>>, _priv_api: Arc<Mutex<PrivXmrigApi>>, args: Vec<String>, path: std::path::PathBuf, sudo: Arc<Mutex<SudoState>>, mut api_ip_port: String) {
async fn spawn_xmrig_watchdog(process: Arc<Mutex<Process>>, gui_api: Arc<Mutex<PubXmrigApi>>, pub_api: Arc<Mutex<PubXmrigApi>>, args: Vec<String>, path: std::path::PathBuf, sudo: Arc<Mutex<SudoState>>, mut api_ip_port: String) {
// 1a. Create PTY
debug!("XMRig | Creating PTY...");
let pty = portable_pty::native_pty_system();
@ -1977,9 +1968,9 @@ mod test {
assert_eq!(p.solo_block_mean.to_string(), "5 months, 21 days, 9 hours, 52 minutes");
assert_eq!(p.p2pool_block_mean.to_string(), "3 days, 11 hours, 20 minutes");
assert_eq!(p.p2pool_share_mean.to_string(), "8 minutes, 20 seconds");
assert_eq!(p.p2pool_percent.to_string(), "0.04%");
assert_eq!(p.user_p2pool_percent.to_string(), "2%");
assert_eq!(p.user_monero_percent.to_string(), "0.0008%");
assert_eq!(p.p2pool_percent.to_string(), "0.040000%");
assert_eq!(p.user_p2pool_percent.to_string(), "2.000000%");
assert_eq!(p.user_monero_percent.to_string(), "0.000800%");
drop(p);
}

View file

@ -1685,10 +1685,10 @@ XMRig console byte length: {}\n
P2POOL_VERSION,
XMRIG_VERSION,
self.now.elapsed().as_secs_f32(),
self.state.gupax.selected_width as u16,
self.state.gupax.selected_height as u16,
self.width as u16,
self.height as u16,
self.state.gupax.selected_width,
self.state.gupax.selected_height,
self.width,
self.height,
OS_NAME,
self.max_threads,
self.pid,

View file

@ -133,7 +133,7 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
} else if self.submenu == Submenu::P2pool {
let api = lock!(gupax_p2pool_api);
let text = height / 25.0;
let log = height / 2.5;
let log = height / 2.8;
ui.style_mut().override_text_style = Some(Monospace);
// Payout Text + PayoutView buttons
ui.group(|ui| {
@ -180,9 +180,9 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
let button = (width/20.0)-(SPACE*1.666);
ui.group(|ui| { ui.horizontal(|ui| {
ui.set_min_width(width-SPACE);
if ui.add_sized([button*2.0, text], SelectableLabel::new(self.manual_hash == false, "Automatic")).on_hover_text(STATUS_SUBMENU_AUTOMATIC).clicked() {self.manual_hash = false; }
if ui.add_sized([button*2.0, text], SelectableLabel::new(!self.manual_hash, "Automatic")).on_hover_text(STATUS_SUBMENU_AUTOMATIC).clicked() {self.manual_hash = false; }
ui.separator();
if ui.add_sized([button*2.0, text], SelectableLabel::new(self.manual_hash == true, "Manual")).on_hover_text(STATUS_SUBMENU_MANUAL).clicked() { self.manual_hash = true; }
if ui.add_sized([button*2.0, text], SelectableLabel::new(self.manual_hash, "Manual")).on_hover_text(STATUS_SUBMENU_MANUAL).clicked() { self.manual_hash = true; }
ui.separator();
ui.set_enabled(self.manual_hash);
if ui.add_sized([button, text], SelectableLabel::new(self.hash_metric == Hash::Hash, "Hash")).on_hover_text(STATUS_SUBMENU_HASH).clicked() { self.hash_metric = Hash::Hash; }
@ -200,7 +200,7 @@ pub fn show(&mut self, sys: &Arc<Mutex<Sys>>, p2pool_api: &Arc<Mutex<PubP2poolAp
ui.set_enabled(p2pool_alive);
let text = height / 25.0;
let width = (width/3.0)-(SPACE*1.666);
let min_height = ui.available_height()/1.35;
let min_height = ui.available_height()/1.3;
let api = lock!(p2pool_api);
ui.horizontal(|ui| {
ui.group(|ui| { ui.vertical(|ui| {