mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
main: integrate Syncing
signal
This commit is contained in:
parent
e425388dc8
commit
7b56a7b900
5 changed files with 32 additions and 15 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1951,7 +1951,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gupax"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arti-client",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gupax"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
authors = ["hinto-janai <hinto.janai@protonmail.com>"]
|
||||
description = "GUI for P2Pool+XMRig"
|
||||
documentation = "https://github.com/hinto-janai/gupax"
|
||||
|
|
|
@ -85,10 +85,11 @@ pub const P2POOL_API_PATH_POOL: &str = "pool/stats";
|
|||
pub const XMRIG_API_URI: &str = "1/summary"; // The default relative URI of XMRig's API
|
||||
|
||||
// Process state tooltips (online, offline, etc)
|
||||
pub const P2POOL_ALIVE: &str = "P2Pool is online";
|
||||
pub const P2POOL_DEAD: &str = "P2Pool is offline";
|
||||
pub const P2POOL_FAILED: &str = "P2Pool is offline and failed when exiting";
|
||||
pub const P2POOL_MIDDLE: &str = "P2Pool is in the middle of (re)starting/stopping";
|
||||
pub const P2POOL_ALIVE: &str = "P2Pool is online and fully synchronized";
|
||||
pub const P2POOL_DEAD: &str = "P2Pool is offline";
|
||||
pub const P2POOL_FAILED: &str = "P2Pool is offline and failed when exiting";
|
||||
pub const P2POOL_MIDDLE: &str = "P2Pool is in the middle of (re)starting/stopping";
|
||||
pub const P2POOL_SYNCING: &str = "P2Pool is still syncing. This indicator will turn GREEN when P2Pool is ready";
|
||||
|
||||
pub const XMRIG_ALIVE: &str = "XMRig is online";
|
||||
pub const XMRIG_DEAD: &str = "XMRig is offline";
|
||||
|
@ -104,6 +105,7 @@ pub const SPACE: f32 = 10.0;
|
|||
// Some colors
|
||||
pub const RED: egui::Color32 = egui::Color32::from_rgb(230, 50, 50);
|
||||
pub const GREEN: egui::Color32 = egui::Color32::from_rgb(100, 230, 100);
|
||||
pub const BLUE: egui::Color32 = egui::Color32::from_rgb(100, 175, 255);
|
||||
pub const YELLOW: egui::Color32 = egui::Color32::from_rgb(230, 230, 100);
|
||||
pub const BRIGHT_YELLOW: egui::Color32 = egui::Color32::from_rgb(250, 250, 100);
|
||||
pub const BONE: egui::Color32 = egui::Color32::from_rgb(190, 190, 190); // In between LIGHT_GRAY <-> GRAY
|
||||
|
|
|
@ -179,12 +179,18 @@ impl Process {
|
|||
|
||||
// Convenience functions
|
||||
pub fn is_alive(&self) -> bool {
|
||||
self.state == ProcessState::Alive || self.state == ProcessState::Middle
|
||||
self.state == ProcessState::Alive ||
|
||||
self.state == ProcessState::Middle ||
|
||||
self.state == ProcessState::Syncing
|
||||
}
|
||||
|
||||
pub fn is_waiting(&self) -> bool {
|
||||
self.state == ProcessState::Middle || self.state == ProcessState::Waiting
|
||||
}
|
||||
|
||||
pub fn is_syncing(&self) -> bool {
|
||||
self.state == ProcessState::Syncing
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [Process*] Enum
|
||||
|
@ -195,6 +201,9 @@ pub enum ProcessState {
|
|||
Failed, // Process is dead AND exited with a bad code, RED!
|
||||
Middle, // Process is in the middle of something ([re]starting/stopping), YELLOW!
|
||||
Waiting, // Process was successfully killed by a restart, and is ready to be started again, YELLOW!
|
||||
|
||||
// Only for P2Pool.
|
||||
Syncing,
|
||||
}
|
||||
|
||||
impl Default for ProcessState { fn default() -> Self { Self::Dead } }
|
||||
|
@ -479,7 +488,7 @@ impl Helper {
|
|||
// 2. Set process state
|
||||
debug!("P2Pool | Setting process state...");
|
||||
let mut lock = lock!(process);
|
||||
lock.state = ProcessState::Alive;
|
||||
lock.state = ProcessState::Syncing;
|
||||
lock.signal = ProcessSignal::None;
|
||||
lock.start = Instant::now();
|
||||
let reader = pair.master.try_clone_reader().unwrap(); // Get STDOUT/STDERR before moving the PTY
|
||||
|
@ -647,7 +656,7 @@ impl Helper {
|
|||
|
||||
// Always update from output
|
||||
debug!("P2Pool Watchdog | Starting [update_from_output()]");
|
||||
PubP2poolApi::update_from_output(&pub_api, &output_parse, &output_pub, start.elapsed(), ®ex);
|
||||
PubP2poolApi::update_from_output(&pub_api, &output_parse, &output_pub, start.elapsed(), ®ex, &process);
|
||||
|
||||
// Read [local] API
|
||||
debug!("P2Pool Watchdog | Attempting [local] API file read");
|
||||
|
@ -1254,7 +1263,6 @@ pub struct PubP2poolApi {
|
|||
pub xmr_hour: f64,
|
||||
pub xmr_day: f64,
|
||||
pub xmr_month: f64,
|
||||
pub synchronized: bool,
|
||||
// Local API
|
||||
pub hashrate_15m: HumanNumber,
|
||||
pub hashrate_1h: HumanNumber,
|
||||
|
@ -1313,7 +1321,6 @@ impl PubP2poolApi {
|
|||
xmr_hour: 0.0,
|
||||
xmr_day: 0.0,
|
||||
xmr_month: 0.0,
|
||||
synchronized: false,
|
||||
hashrate_15m: HumanNumber::unknown(),
|
||||
hashrate_1h: HumanNumber::unknown(),
|
||||
hashrate_24h: HumanNumber::unknown(),
|
||||
|
@ -1377,7 +1384,14 @@ impl PubP2poolApi {
|
|||
}
|
||||
|
||||
// Mutate "watchdog"'s [PubP2poolApi] with data the process output.
|
||||
fn update_from_output(public: &Arc<Mutex<Self>>, output_parse: &Arc<Mutex<String>>, output_pub: &Arc<Mutex<String>>, elapsed: std::time::Duration, regex: &P2poolRegex) {
|
||||
fn update_from_output(
|
||||
public: &Arc<Mutex<Self>>,
|
||||
output_parse: &Arc<Mutex<String>>,
|
||||
output_pub: &Arc<Mutex<String>>,
|
||||
elapsed: std::time::Duration,
|
||||
regex: &P2poolRegex,
|
||||
process: &Arc<Mutex<Process>>,
|
||||
) {
|
||||
// 1. Take the process's current output buffer and combine it with Pub (if not empty)
|
||||
let mut output_pub = lock!(output_pub);
|
||||
if !output_pub.is_empty() {
|
||||
|
@ -1388,9 +1402,9 @@ impl PubP2poolApi {
|
|||
let mut output_parse = lock!(output_parse);
|
||||
let (payouts_new, xmr_new) = Self::calc_payouts_and_xmr(&output_parse, regex);
|
||||
// Check for "SYNCHRONIZED" only if we aren't already.
|
||||
if !lock!(public).synchronized {
|
||||
if lock!(process).state == ProcessState::Syncing {
|
||||
if regex.synchronized.is_match(&output_parse) {
|
||||
lock!(public).synchronized = true;
|
||||
lock!(process).state = ProcessState::Alive;
|
||||
}
|
||||
}
|
||||
// 3. Throw away [output_parse]
|
||||
|
|
|
@ -1519,13 +1519,14 @@ impl eframe::App for App {
|
|||
Dead => ui.add_sized([width, height], Label::new(RichText::new("P2Pool ⏺").color(GRAY))).on_hover_text(P2POOL_DEAD),
|
||||
Failed => ui.add_sized([width, height], Label::new(RichText::new("P2Pool ⏺").color(RED))).on_hover_text(P2POOL_FAILED),
|
||||
Middle|Waiting => ui.add_sized([width, height], Label::new(RichText::new("P2Pool ⏺").color(YELLOW))).on_hover_text(P2POOL_MIDDLE),
|
||||
Syncing => ui.add_sized([width, height], Label::new(RichText::new("P2Pool ⏺").color(BLUE))).on_hover_text(P2POOL_SYNCING),
|
||||
};
|
||||
ui.separator();
|
||||
match xmrig_state {
|
||||
Alive => ui.add_sized([width, height], Label::new(RichText::new("XMRig ⏺").color(GREEN))).on_hover_text(XMRIG_ALIVE),
|
||||
Dead => ui.add_sized([width, height], Label::new(RichText::new("XMRig ⏺").color(GRAY))).on_hover_text(XMRIG_DEAD),
|
||||
Failed => ui.add_sized([width, height], Label::new(RichText::new("XMRig ⏺").color(RED))).on_hover_text(XMRIG_FAILED),
|
||||
Middle|Waiting => ui.add_sized([width, height], Label::new(RichText::new("XMRig ⏺").color(YELLOW))).on_hover_text(XMRIG_MIDDLE),
|
||||
Middle|Waiting|Syncing => ui.add_sized([width, height], Label::new(RichText::new("XMRig ⏺").color(YELLOW))).on_hover_text(XMRIG_MIDDLE),
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue