diff --git a/Cargo.lock b/Cargo.lock index 34c816f..a9bb987 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1798,7 +1798,7 @@ dependencies = [ [[package]] name = "gupax" -version = "1.0.0" +version = "1.0.1" dependencies = [ "anyhow", "arti-client", diff --git a/Cargo.toml b/Cargo.toml index b963cb0..8c3f150 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gupax" -version = "1.0.0" +version = "1.0.1" authors = ["hinto-janaiyo "] description = "GUI for P2Pool+XMRig" documentation = "https://github.com/hinto-janaiyo/gupax" diff --git a/src/constants.rs b/src/constants.rs index b3a89f8..1f9981a 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -154,13 +154,17 @@ pub const STATUS_P2POOL_HASHRATE: &str = "The total amount of hashrate your P2Po pub const STATUS_P2POOL_SHARES: &str = "The total amount of shares found on P2Pool"; pub const STATUS_P2POOL_EFFORT: &str = "The average amount of effort needed to find a share, and the current effort"; pub const STATUS_P2POOL_CONNECTIONS: &str = "The total amount of miner connections on this P2Pool"; +pub const STATUS_P2POOL_MONERO_NODE: &str = "The Monero node being used by P2Pool"; +pub const STATUS_P2POOL_POOL: &str = "The P2Pool sidechain you're currently connected to"; +pub const STATUS_P2POOL_ADDRESS: &str = "The Monero address P2Pool will send payouts to"; //-- pub const STATUS_XMRIG_UPTIME: &str = "How long XMRig has been online"; -pub const STATUS_XMRIG_CPU: &str = "The average CPU load of XMRig"; +pub const STATUS_XMRIG_CPU: &str = "The average CPU load of XMRig. [1.0] represents 1 thread is maxed out, e.g: If you have 8 threads, [4.0] means half your threads are maxed out."; pub const STATUS_XMRIG_HASHRATE: &str = "The average hashrate of XMRig"; pub const STATUS_XMRIG_DIFFICULTY: &str = "The current difficulty of the job XMRig is working on"; pub const STATUS_XMRIG_SHARES: &str = "The amount of accepted and rejected shares"; pub const STATUS_XMRIG_POOL: &str = "The pool XMRig is currently mining to"; +pub const STATUS_XMRIG_THREADS: &str = "The amount of threads XMRig is currently using"; // Gupax pub const GUPAX_UPDATE: &str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically"; diff --git a/src/helper.rs b/src/helper.rs index 859684e..a3e99f0 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -329,6 +329,15 @@ impl Helper { }); } + // Takes in a 95-char Monero address, returns the first and last + // 6 characters separated with dots like so: [4abcde...abcdef] + fn head_tail_of_monero_address(address: &str) -> String { + if address.len() < 95 { return "???".to_string() } + let head = &address[0..5]; + let tail = &address[89..95]; + head.to_owned() + "..." + tail + } + // Takes in some [State/P2pool] and parses it to build the actual command arguments. // Returns the [Vec] of actual arguments, and mutates the [ImgP2pool] for the main GUI thread // It returns a value... and mutates a deeply nested passed argument... this is some pretty bad code... @@ -351,12 +360,11 @@ impl Helper { args.push("--no-color".to_string()); // Remove color escape sequences, Gupax terminal can't parse it :( args.push("--mini".to_string()); // P2Pool Mini *helper.lock().unwrap().img_p2pool.lock().unwrap() = ImgP2pool { - mini: true, - address: state.address.clone(), + mini: "P2Pool Mini".to_string(), + address: Self::head_tail_of_monero_address(&state.address), host: ip.to_string(), rpc: rpc.to_string(), zmq: zmq.to_string(), - log_level: "3".to_string(), out_peers: "10".to_string(), in_peers: "10".to_string(), }; @@ -370,19 +378,20 @@ impl Helper { let mut last = ""; let lock = helper.lock().unwrap(); let mut p2pool_image = lock.img_p2pool.lock().unwrap(); + let mut mini = false; for arg in state.arguments.split_whitespace() { match last { - "--mini" => p2pool_image.mini = true, - "--wallet" => p2pool_image.address = arg.to_string(), + "--mini" => { mini = true; p2pool_image.mini = "P2Pool Mini".to_string(); }, + "--wallet" => p2pool_image.address = Self::head_tail_of_monero_address(arg), "--host" => p2pool_image.host = arg.to_string(), "--rpc-port" => p2pool_image.rpc = arg.to_string(), "--zmq-port" => p2pool_image.zmq = arg.to_string(), - "--loglevel" => p2pool_image.log_level = arg.to_string(), "--out-peers" => p2pool_image.out_peers = arg.to_string(), "--in-peers" => p2pool_image.in_peers = arg.to_string(), "--data-api" => api_path = PathBuf::from(arg), _ => (), } + if !mini { p2pool_image.mini = "P2Pool Main".to_string(); } args.push(arg.to_string()); last = arg; } @@ -400,12 +409,11 @@ impl Helper { args.push("--no-color".to_string()); // Remove color escape sequences if state.mini { args.push("--mini".to_string()); }; // Mini *helper.lock().unwrap().img_p2pool.lock().unwrap() = ImgP2pool { - mini: state.mini, - address: state.address.clone(), + mini: if state.mini { "P2Pool Mini".to_string() } else { "P2Pool Main".to_string() }, + address: Self::head_tail_of_monero_address(&state.address), host: state.selected_ip.to_string(), rpc: state.selected_rpc.to_string(), zmq: state.selected_zmq.to_string(), - log_level: state.log_level.to_string(), out_peers: state.out_peers.to_string(), in_peers: state.in_peers.to_string(), }; @@ -1333,14 +1341,13 @@ impl P2poolRegex { // No need for an [Arc] since the Helper thread doesn't need this information. #[derive(Debug, Clone)] pub struct ImgP2pool { - pub mini: bool, // Did the user start on the mini-chain? + pub mini: String, // Did the user start on the mini-chain? pub address: String, // What address is the current p2pool paying out to? (This gets shortened to [4xxxxx...xxxxxx]) pub host: String, // What monerod are we using? pub rpc: String, // What is the RPC port? pub zmq: String, // What is the ZMQ port? pub out_peers: String, // How many out-peers? pub in_peers: String, // How many in-peers? - pub log_level: String, // What log level? } impl Default for ImgP2pool { @@ -1352,14 +1359,13 @@ impl Default for ImgP2pool { impl ImgP2pool { pub fn new() -> Self { Self { - mini: true, - address: String::new(), - host: String::new(), - rpc: String::new(), - zmq: String::new(), - out_peers: String::new(), - in_peers: String::new(), - log_level: String::new(), + mini: String::from("???"), + address: String::from("???"), + host: String::from("???"), + rpc: String::from("???"), + zmq: String::from("???"), + out_peers: String::from("???"), + in_peers: String::from("???"), } } } @@ -1585,8 +1591,8 @@ impl Default for ImgXmrig { impl ImgXmrig { pub fn new() -> Self { Self { - threads: "1".to_string(), - url: "127.0.0.1:3333 (Local P2Pool)".to_string(), + threads: "???".to_string(), + url: "???".to_string(), } } } @@ -1599,7 +1605,6 @@ pub struct PubXmrigApi { pub worker_id: String, pub resources: HumanNumber, pub hashrate: HumanNumber, - pub pool: String, pub diff: HumanNumber, pub accepted: HumanNumber, pub rejected: HumanNumber, @@ -1619,7 +1624,6 @@ impl PubXmrigApi { worker_id: "???".to_string(), resources: HumanNumber::unknown(), hashrate: HumanNumber::unknown(), - pool: "???".to_string(), diff: HumanNumber::unknown(), accepted: HumanNumber::unknown(), rejected: HumanNumber::unknown(), @@ -1657,7 +1661,6 @@ impl PubXmrigApi { worker_id: private.worker_id, resources: HumanNumber::from_load(private.resources.load_average), hashrate: HumanNumber::from_hashrate(private.hashrate.total), - pool: private.connection.pool, diff: HumanNumber::from_u128(private.connection.diff), accepted: HumanNumber::from_u128(private.connection.accepted), rejected: HumanNumber::from_u128(private.connection.rejected), @@ -1714,7 +1717,6 @@ impl Resources { #[derive(Debug, Serialize, Deserialize, Clone)] struct Connection { - pool: String, diff: u128, accepted: u128, rejected: u128, @@ -1722,7 +1724,6 @@ struct Connection { impl Connection { fn new() -> Self { Self { - pool: String::new(), diff: 0, accepted: 0, rejected: 0, @@ -2022,7 +2023,6 @@ r#"{ ] }, "connection": { - "pool": "localhost:3333", "diff": 123, "accepted": 123, "rejected": 123 diff --git a/src/main.rs b/src/main.rs index 275d102..1e1bc3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1262,7 +1262,7 @@ impl eframe::App for App { self.error_state.reset(); } }, - Okay|WindowsAdmin|Debug => if key.is_esc() || ui.add_sized([width, height], Button::new("Okay")).clicked() { self.error_state.reset(); }, + Okay|WindowsAdmin => if key.is_esc() || ui.add_sized([width, height], Button::new("Okay")).clicked() { self.error_state.reset(); }, Debug => if key.is_esc() { self.error_state.reset(); }, Quit => if ui.add_sized([width, height], Button::new("Quit")).clicked() { exit(1); }, } @@ -1579,10 +1579,14 @@ Gupax PATH: {}\n P2Pool PATH: {}\n XMRig PATH: {}\n P2Pool console byte length: {}\n -XMRig console byte length: {}\n\n\n ---------------------- WORKING STATE --------------------- -{:#?}\n\n\n ---------------------- ORIGINAL STATE --------------------- +XMRig console byte length: {}\n +------------------------------------------ P2POOL IMAGE ------------------------------------------ +{:#?}\n +------------------------------------------ XMRIG IMAGE ------------------------------------------ +{:#?}\n +------------------------------------------ WORKING STATE ------------------------------------------ +{:#?}\n +------------------------------------------ ORIGINAL STATE ------------------------------------------ {:#?}", GUPAX_VERSION, P2POOL_VERSION, @@ -1609,6 +1613,8 @@ XMRig console byte length: {}\n\n\n self.state.gupax.absolute_xmrig_path.display(), self.p2pool_api.lock().unwrap().output.len(), self.xmrig_api.lock().unwrap().output.len(), + self.p2pool_img.lock().unwrap(), + self.xmrig_img.lock().unwrap(), self.state, self.og.lock().unwrap(), ); @@ -1643,7 +1649,7 @@ XMRig console byte length: {}\n\n\n } Tab::Status => { debug!("App | Entering [Status] Tab"); - Status::show(&self.pub_sys, &self.p2pool_api, &self.xmrig_api, &self.p2pool_img, &self.xmrig_img, p2pool_is_alive, xmrig_is_alive, self.width, self.height, ctx, ui); + Status::show(&self.pub_sys, &self.p2pool_api, &self.xmrig_api, &self.p2pool_img, &self.xmrig_img, p2pool_is_alive, xmrig_is_alive, self.max_threads, self.width, self.height, ctx, ui); } Tab::Gupax => { debug!("App | Entering [Gupax] Tab"); diff --git a/src/status.rs b/src/status.rs index 131ed90..d6699f5 100644 --- a/src/status.rs +++ b/src/status.rs @@ -26,7 +26,9 @@ use crate::{ use std::sync::{Arc,Mutex}; use log::*; use egui::{ - Label,RichText,TextStyle + Label,RichText,TextStyle, + TextStyle::Monospace, + TextStyle::Name, }; // Main data structure for the Status tab @@ -34,7 +36,7 @@ use egui::{ pub struct Status {} impl Status { -pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_api: &Arc>, _p2pool_img: &Arc>, _xmrig_img: &Arc>, p2pool_alive: bool, xmrig_alive: bool, width: f32, height: f32, _ctx: &egui::Context, ui: &mut egui::Ui) { +pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_api: &Arc>, p2pool_img: &Arc>, xmrig_img: &Arc>, p2pool_alive: bool, xmrig_alive: bool, max_threads: usize, width: f32, height: f32, _ctx: &egui::Context, ui: &mut egui::Ui) { let width = (width/3.0)-(SPACE*1.666); let min_height = height/1.14; let height = height/25.0; @@ -43,7 +45,8 @@ pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_ ui.group(|ui| { ui.vertical(|ui| { debug!("Status Tab | Rendering [Gupax]"); ui.set_min_height(min_height); - ui.add_sized([width, height*2.0], Label::new(RichText::new("[Gupax]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("Gupax is online"); + ui.add_sized([width, height], Label::new(RichText::new("[Gupax]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("Gupax is online"); + ui.style_mut().override_text_style = Some(Monospace); let sys = sys.lock().unwrap(); ui.add_sized([width, height], Label::new(RichText::new("Uptime").underline().color(BONE))).on_hover_text(STATUS_GUPAX_UPTIME); ui.add_sized([width, height], Label::new(sys.gupax_uptime.to_string())); @@ -64,7 +67,9 @@ pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_ debug!("Status Tab | Rendering [P2Pool]"); ui.set_enabled(p2pool_alive); ui.set_min_height(min_height); - ui.add_sized([width, height*2.0], Label::new(RichText::new("[P2Pool]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("P2Pool is online").on_disabled_hover_text("P2Pool is offline"); + ui.add_sized([width, height], Label::new(RichText::new("[P2Pool]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("P2Pool is online").on_disabled_hover_text("P2Pool is offline"); + let height = height/1.4; + ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into())); let api = p2pool_api.lock().unwrap(); ui.add_sized([width, height], Label::new(RichText::new("Uptime").underline().color(BONE))).on_hover_text(STATUS_P2POOL_UPTIME); ui.add_sized([width, height], Label::new(format!("{}", api.uptime))); @@ -76,12 +81,20 @@ pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_ ui.add_sized([width, height], Label::new(RichText::new("XMR Mined").underline().color(BONE))).on_hover_text(STATUS_P2POOL_XMR); ui.add_sized([width, height], Label::new(format!("Total: {:.13} XMR", api.xmr))); ui.add_sized([width, height], Label::new(format!("[{:.7}/hour]\n[{:.7}/day]\n[{:.7}/month]", api.xmr_hour, api.xmr_day, api.xmr_month))); - ui.add_sized([width, height], Label::new(RichText::new("Hashrate [15m/1h/24h]").underline().color(BONE))).on_hover_text(STATUS_P2POOL_HASHRATE); - ui.add_sized([width, height], Label::new(format!("[{} H/s] [{} H/s] [{} H/s]", api.hashrate_15m, api.hashrate_1h, api.hashrate_24h))); + ui.add_sized([width, height], Label::new(RichText::new("Hashrate (15m/1h/24h)").underline().color(BONE))).on_hover_text(STATUS_P2POOL_HASHRATE); + ui.add_sized([width, height], Label::new(format!("[{} H/s]\n[{} H/s]\n[{} H/s]", api.hashrate_15m, api.hashrate_1h, api.hashrate_24h))); ui.add_sized([width, height], Label::new(RichText::new("Miners Connected").underline().color(BONE))).on_hover_text(STATUS_P2POOL_CONNECTIONS); ui.add_sized([width, height], Label::new(format!("{}", api.connections))); ui.add_sized([width, height], Label::new(RichText::new("Effort").underline().color(BONE))).on_hover_text(STATUS_P2POOL_EFFORT); ui.add_sized([width, height], Label::new(format!("[Average: {}] [Current: {}]", api.average_effort, api.current_effort))); + let img = p2pool_img.lock().unwrap(); + ui.add_sized([width, height], Label::new(RichText::new("Monero Node").underline().color(BONE))).on_hover_text(STATUS_P2POOL_MONERO_NODE); + ui.add_sized([width, height], Label::new(format!("[IP: {}]\n[RPC: {}] [ZMQ: {}]", &img.host, &img.rpc, &img.zmq))); + ui.add_sized([width, height], Label::new(RichText::new("Sidechain").underline().color(BONE))).on_hover_text(STATUS_P2POOL_POOL); + ui.add_sized([width, height], Label::new(&img.mini)); + ui.add_sized([width, height], Label::new(RichText::new("Address").underline().color(BONE))).on_hover_text(STATUS_P2POOL_ADDRESS); + ui.add_sized([width, height], Label::new(&img.address)); + drop(img); drop(api); })}); // [XMRig] @@ -89,7 +102,8 @@ pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_ debug!("Status Tab | Rendering [XMRig]"); ui.set_enabled(xmrig_alive); ui.set_min_height(min_height); - ui.add_sized([width, height*2.0], Label::new(RichText::new("[XMRig]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("XMRig is online").on_disabled_hover_text("XMRig is offline"); + ui.add_sized([width, height], Label::new(RichText::new("[XMRig]").color(LIGHT_GRAY).text_style(TextStyle::Name("MonospaceLarge".into())))).on_hover_text("XMRig is online").on_disabled_hover_text("XMRig is offline"); + ui.style_mut().override_text_style = Some(Monospace); let api = xmrig_api.lock().unwrap(); ui.add_sized([width, height], Label::new(RichText::new("Uptime").underline().color(BONE))).on_hover_text(STATUS_XMRIG_UPTIME); ui.add_sized([width, height], Label::new(format!("{}", api.uptime))); @@ -100,9 +114,11 @@ pub fn show(sys: &Arc>, p2pool_api: &Arc>, xmrig_ ui.add_sized([width, height], Label::new(RichText::new("Difficulty").underline().color(BONE))).on_hover_text(STATUS_XMRIG_DIFFICULTY); ui.add_sized([width, height], Label::new(format!("{}", api.diff))); ui.add_sized([width, height], Label::new(RichText::new("Shares").underline().color(BONE))).on_hover_text(STATUS_XMRIG_SHARES); - ui.add_sized([width, height], Label::new(format!("[Accepted: {}]\n[Rejected: {}]", api.accepted, api.rejected))); + ui.add_sized([width, height], Label::new(format!("[Accepted: {}] [Rejected: {}]", api.accepted, api.rejected))); ui.add_sized([width, height], Label::new(RichText::new("Pool").underline().color(BONE))).on_hover_text(STATUS_XMRIG_POOL); - ui.add_sized([width, height], Label::new(api.pool.to_string())); + ui.add_sized([width, height], Label::new(&xmrig_img.lock().unwrap().url)); + ui.add_sized([width, height], Label::new(RichText::new("Threads").underline().color(BONE))).on_hover_text(STATUS_XMRIG_THREADS); + ui.add_sized([width, height], Label::new(format!("{}/{}", &xmrig_img.lock().unwrap().threads, max_threads))); drop(api); })}); }); diff --git a/utils/prepare.sh b/utils/prepare.sh index ed1eb92..49c96a9 100755 --- a/utils/prepare.sh +++ b/utils/prepare.sh @@ -13,6 +13,7 @@ sudo -v # get old GUPAX_VER OLD_VER="v$(grep -m1 "version" Cargo.toml | grep -o "[0-9].[0-9].[0-9]")" +OLD_VER_NUM="$(grep -m1 "version" Cargo.toml | grep -o "[0-9].[0-9].[0-9]")" # get p2pool/xmrig version P2POOL_VERSION="$(grep "P2POOL_VERSION" src/constants.rs | grep -o "\"v[0-9].*\"")" @@ -20,7 +21,7 @@ XMRIG_VERSION="$(grep "XMRIG_VERSION" src/constants.rs | grep -o "\"v[0-9].*\"") # sed change sed -i "s/$OLD_VER/$1/g" README.md -sed -i "s/$OLD_VER/$1/" Cargo.toml +sed -i 's/^version = "$OLD_VER_NUM"/$1/' Cargo.toml # changelog cat << EOM > CHANGELOG.md.new