mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 15:27:46 +00:00
Merge branch 'dev' of github.com:mostafaei2002/gupaxx into dev
This commit is contained in:
commit
b0834d4c34
6 changed files with 158 additions and 124 deletions
|
@ -99,11 +99,8 @@ impl Gupax {
|
||||||
ui.add_sized(size, Checkbox::new(&mut self.auto_xmrig, "Auto-XMRig"))
|
ui.add_sized(size, Checkbox::new(&mut self.auto_xmrig, "Auto-XMRig"))
|
||||||
.on_hover_text(GUPAX_AUTO_XMRIG);
|
.on_hover_text(GUPAX_AUTO_XMRIG);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.add_sized(
|
ui.add_sized(size, Checkbox::new(&mut self.auto_xp, "Auto-Proxy"))
|
||||||
size,
|
.on_hover_text(GUPAX_AUTO_XMRIG_PROXY);
|
||||||
Checkbox::new(&mut self.auto_xmrig, "Auto-XMRig-Proxy"),
|
|
||||||
)
|
|
||||||
.on_hover_text(GUPAX_AUTO_XMRIG_PROXY);
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.add_sized(size, Checkbox::new(&mut self.auto_xvb, "Auto-XvB"))
|
ui.add_sized(size, Checkbox::new(&mut self.auto_xvb, "Auto-XvB"))
|
||||||
.on_hover_text(GUPAX_AUTO_XVB);
|
.on_hover_text(GUPAX_AUTO_XVB);
|
||||||
|
|
|
@ -51,125 +51,127 @@ impl P2pool {
|
||||||
let text_edit = size.y / 25.0;
|
let text_edit = size.y / 25.0;
|
||||||
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
||||||
// debug!("P2Pool Tab | Rendering [Console]");
|
// debug!("P2Pool Tab | Rendering [Console]");
|
||||||
ui.group(|ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let text = &lock!(api).output;
|
|
||||||
let nb_lines = num_lines(text);
|
|
||||||
let (height, width) = if self.simple {
|
|
||||||
((size.y * 0.38) - SPACE, size.x - SPACE)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
if size.y < 600.0 {
|
|
||||||
size.y * 0.22 - SPACE
|
|
||||||
} else {
|
|
||||||
size.y * 0.36 - SPACE
|
|
||||||
},
|
|
||||||
width - SPACE,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
|
||||||
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.stick_to_bottom(true)
|
|
||||||
.max_width(width)
|
|
||||||
.max_height(height)
|
|
||||||
.auto_shrink([false; 2])
|
|
||||||
// .show_viewport(ui, |ui, _| {
|
|
||||||
.show_rows(
|
|
||||||
ui,
|
|
||||||
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
|
|
||||||
nb_lines,
|
|
||||||
|ui, row_range| {
|
|
||||||
for i in row_range {
|
|
||||||
if let Some(line) = text.lines().nth(i) {
|
|
||||||
ui.label(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if !self.simple {
|
|
||||||
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
|
||||||
ui.separator();
|
|
||||||
let response = ui
|
|
||||||
.add_sized(
|
|
||||||
[width, text_edit],
|
|
||||||
TextEdit::hint_text(
|
|
||||||
TextEdit::singleline(buffer),
|
|
||||||
r#"Type a command (e.g "help" or "status") and press Enter"#,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.on_hover_text(P2POOL_INPUT);
|
|
||||||
// If the user pressed enter, dump buffer contents into the process STDIN
|
|
||||||
if response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
|
|
||||||
response.request_focus(); // Get focus back
|
|
||||||
let buffer = std::mem::take(buffer); // Take buffer
|
|
||||||
let mut process = lock!(process); // Lock
|
|
||||||
if process.is_alive() {
|
|
||||||
process.input.push(buffer);
|
|
||||||
} // Push only if alive
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Args
|
|
||||||
if !self.simple {
|
|
||||||
debug!("P2Pool Tab | Rendering [Arguments]");
|
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.horizontal(|ui| {
|
let text = &lock!(api).output;
|
||||||
let width = (width / 10.0) - SPACE;
|
let nb_lines = num_lines(text);
|
||||||
ui.add_sized([width, text_edit], Label::new("Command arguments:"));
|
let (height, width) = if self.simple {
|
||||||
ui.add_sized(
|
((size.y * 0.38) - SPACE, size.x - SPACE)
|
||||||
[ui.available_width(), text_edit],
|
} else {
|
||||||
TextEdit::hint_text(
|
(
|
||||||
TextEdit::singleline(&mut self.arguments),
|
if size.y < 600.0 {
|
||||||
r#"--wallet <...> --host <...>"#,
|
size.y * 0.22 - SPACE
|
||||||
),
|
} else {
|
||||||
|
size.y * 0.36 - SPACE
|
||||||
|
},
|
||||||
|
width - SPACE,
|
||||||
)
|
)
|
||||||
.on_hover_text(P2POOL_ARGUMENTS);
|
};
|
||||||
self.arguments.truncate(1024);
|
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
||||||
})
|
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
|
||||||
|
egui::ScrollArea::vertical()
|
||||||
|
.stick_to_bottom(true)
|
||||||
|
.max_width(width)
|
||||||
|
.max_height(height)
|
||||||
|
.auto_shrink([false; 2])
|
||||||
|
// .show_viewport(ui, |ui, _| {
|
||||||
|
.show_rows(
|
||||||
|
ui,
|
||||||
|
ui.text_style_height(&TextStyle::Name("MonospaceSmall".into())),
|
||||||
|
nb_lines,
|
||||||
|
|ui, row_range| {
|
||||||
|
for i in row_range {
|
||||||
|
if let Some(line) = text.lines().nth(i) {
|
||||||
|
ui.label(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if !self.simple {
|
||||||
|
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
||||||
|
ui.separator();
|
||||||
|
let response = ui
|
||||||
|
.add_sized(
|
||||||
|
[width, text_edit],
|
||||||
|
TextEdit::hint_text(
|
||||||
|
TextEdit::singleline(buffer),
|
||||||
|
r#"Type a command (e.g "help" or "status") and press Enter"#,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.on_hover_text(P2POOL_INPUT);
|
||||||
|
// If the user pressed enter, dump buffer contents into the process STDIN
|
||||||
|
if response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
|
||||||
|
response.request_focus(); // Get focus back
|
||||||
|
let buffer = std::mem::take(buffer); // Take buffer
|
||||||
|
let mut process = lock!(process); // Lock
|
||||||
|
if process.is_alive() {
|
||||||
|
process.input.push(buffer);
|
||||||
|
} // Push only if alive
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ui.set_enabled(self.arguments.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Address
|
//---------------------------------------------------------------------------------------------------- Args
|
||||||
debug!("P2Pool Tab | Rendering [Address]");
|
if !self.simple {
|
||||||
ui.group(|ui| {
|
debug!("P2Pool Tab | Rendering [Arguments]");
|
||||||
let width = width - SPACE;
|
ui.group(|ui| {
|
||||||
ui.spacing_mut().text_edit_width = (width) - (SPACE * 3.0);
|
ui.horizontal(|ui| {
|
||||||
let text;
|
let width = (width / 10.0) - SPACE;
|
||||||
let color;
|
ui.add_sized([width, text_edit], Label::new("Command arguments:"));
|
||||||
let len = format!("{:02}", self.address.len());
|
ui.add_sized(
|
||||||
if self.address.is_empty() {
|
[ui.available_width(), text_edit],
|
||||||
text = format!("Monero Address [{}/95] ➖", len);
|
TextEdit::hint_text(
|
||||||
color = Color32::LIGHT_GRAY;
|
TextEdit::singleline(&mut self.arguments),
|
||||||
} else if Regexes::addr_ok(&self.address) {
|
r#"--wallet <...> --host <...>"#,
|
||||||
text = format!("Monero Address [{}/95] ✔", len);
|
),
|
||||||
color = Color32::from_rgb(100, 230, 100);
|
)
|
||||||
} else {
|
.on_hover_text(P2POOL_ARGUMENTS);
|
||||||
text = format!("Monero Address [{}/95] ❌", len);
|
self.arguments.truncate(1024);
|
||||||
color = Color32::from_rgb(230, 50, 50);
|
})
|
||||||
|
});
|
||||||
|
ui.set_enabled(self.arguments.is_empty());
|
||||||
}
|
}
|
||||||
ui.add_sized(
|
|
||||||
[width, text_edit],
|
|
||||||
Label::new(RichText::new(text).color(color)),
|
|
||||||
);
|
|
||||||
ui.add_sized(
|
|
||||||
[width, text_edit],
|
|
||||||
TextEdit::hint_text(TextEdit::singleline(&mut self.address), "4..."),
|
|
||||||
)
|
|
||||||
.on_hover_text(P2POOL_ADDRESS);
|
|
||||||
self.address.truncate(95);
|
|
||||||
});
|
|
||||||
|
|
||||||
// let height = ui.available_height();
|
//---------------------------------------------------------------------------------------------------- Address
|
||||||
let size = vec2(width, height);
|
debug!("P2Pool Tab | Rendering [Address]");
|
||||||
if self.simple {
|
ui.group(|ui| {
|
||||||
//---------------------------------------------------------------------------------------------------- Simple
|
let width = width - SPACE;
|
||||||
self.simple(ui, size, ping);
|
ui.spacing_mut().text_edit_width = (width) - (SPACE * 3.0);
|
||||||
//---------------------------------------------------------------------------------------------------- Advanced
|
let text;
|
||||||
} else {
|
let color;
|
||||||
self.advanced(ui, size, text_edit, node_vec);
|
let len = format!("{:02}", self.address.len());
|
||||||
}
|
if self.address.is_empty() {
|
||||||
|
text = format!("Monero Address [{}/95] ➖", len);
|
||||||
|
color = Color32::LIGHT_GRAY;
|
||||||
|
} else if Regexes::addr_ok(&self.address) {
|
||||||
|
text = format!("Monero Address [{}/95] ✔", len);
|
||||||
|
color = Color32::from_rgb(100, 230, 100);
|
||||||
|
} else {
|
||||||
|
text = format!("Monero Address [{}/95] ❌", len);
|
||||||
|
color = Color32::from_rgb(230, 50, 50);
|
||||||
|
}
|
||||||
|
ui.add_sized(
|
||||||
|
[width, text_edit],
|
||||||
|
Label::new(RichText::new(text).color(color)),
|
||||||
|
);
|
||||||
|
ui.add_sized(
|
||||||
|
[width, text_edit],
|
||||||
|
TextEdit::hint_text(TextEdit::singleline(&mut self.address), "4..."),
|
||||||
|
)
|
||||||
|
.on_hover_text(P2POOL_ADDRESS);
|
||||||
|
self.address.truncate(95);
|
||||||
|
});
|
||||||
|
|
||||||
|
// let height = ui.available_height();
|
||||||
|
let size = vec2(width, height);
|
||||||
|
if self.simple {
|
||||||
|
//---------------------------------------------------------------------------------------------------- Simple
|
||||||
|
self.simple(ui, size, ping);
|
||||||
|
//---------------------------------------------------------------------------------------------------- Advanced
|
||||||
|
} else {
|
||||||
|
self.advanced(ui, size, text_edit, node_vec);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ impl Xmrig {
|
||||||
let text_edit = size.y / 25.0;
|
let text_edit = size.y / 25.0;
|
||||||
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
||||||
debug!("XMRig Tab | Rendering [Console]");
|
debug!("XMRig Tab | Rendering [Console]");
|
||||||
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let text = &lock!(api).output;
|
let text = &lock!(api).output;
|
||||||
let nb_lines = num_lines(text);
|
let nb_lines = num_lines(text);
|
||||||
|
@ -483,5 +484,6 @@ impl Xmrig {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ impl XmrigProxy {
|
||||||
let height = size.y;
|
let height = size.y;
|
||||||
let space_h = height / 48.0;
|
let space_h = height / 48.0;
|
||||||
let text_edit = size.y / 25.0;
|
let text_edit = size.y / 25.0;
|
||||||
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
ui.add_space(space_h);
|
ui.add_space(space_h);
|
||||||
ui.style_mut().override_text_style = Some(TextStyle::Heading);
|
ui.style_mut().override_text_style = Some(TextStyle::Heading);
|
||||||
|
@ -424,5 +425,6 @@ impl XmrigProxy {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ impl Helper {
|
||||||
state_xvb,
|
state_xvb,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let xp_alive = lock!(process_xp).state == ProcessState::Alive;
|
let mut xp_alive = false;
|
||||||
// uptime for log of signal check ?
|
// uptime for log of signal check ?
|
||||||
let start = lock!(process).start;
|
let start = lock!(process).start;
|
||||||
// uptime of last run of algo
|
// uptime of last run of algo
|
||||||
|
@ -208,8 +208,12 @@ impl Helper {
|
||||||
debug!("XvB Watchdog | ----------- Start of loop -----------");
|
debug!("XvB Watchdog | ----------- Start of loop -----------");
|
||||||
// Set timer of loop
|
// Set timer of loop
|
||||||
let start_loop = std::time::Instant::now();
|
let start_loop = std::time::Instant::now();
|
||||||
|
// check if first loop the state of Xmrig-Proxy
|
||||||
|
if first_loop {
|
||||||
|
xp_alive = lock!(process_xp).state == ProcessState::Alive;
|
||||||
|
}
|
||||||
// verify if p2pool and xmrig are running, else XvB must be reloaded with another token/address to start verifying the other process.
|
// verify if p2pool and xmrig are running, else XvB must be reloaded with another token/address to start verifying the other process.
|
||||||
check_state_outcauses_xvb(
|
if check_state_outcauses_xvb(
|
||||||
&client,
|
&client,
|
||||||
gui_api,
|
gui_api,
|
||||||
pub_api,
|
pub_api,
|
||||||
|
@ -224,8 +228,12 @@ impl Helper {
|
||||||
state_p2pool,
|
state_p2pool,
|
||||||
state_xmrig,
|
state_xmrig,
|
||||||
state_xp,
|
state_xp,
|
||||||
|
xp_alive,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// check signal
|
// check signal
|
||||||
debug!("XvB | check signal");
|
debug!("XvB | check signal");
|
||||||
|
@ -512,6 +520,7 @@ async fn check_conditions_for_start(
|
||||||
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(XvbNode::default());
|
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(XvbNode::default());
|
||||||
lock!(process_xvb).state = state;
|
lock!(process_xvb).state = state;
|
||||||
}
|
}
|
||||||
|
/// return a bool to continue to next loop if needed.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn check_state_outcauses_xvb(
|
async fn check_state_outcauses_xvb(
|
||||||
client: &Client,
|
client: &Client,
|
||||||
|
@ -528,7 +537,8 @@ async fn check_state_outcauses_xvb(
|
||||||
state_p2pool: &crate::disk::state::P2pool,
|
state_p2pool: &crate::disk::state::P2pool,
|
||||||
state_xmrig: &crate::disk::state::Xmrig,
|
state_xmrig: &crate::disk::state::Xmrig,
|
||||||
state_xp: &crate::disk::state::XmrigProxy,
|
state_xp: &crate::disk::state::XmrigProxy,
|
||||||
) {
|
xp_start_alive: bool,
|
||||||
|
) -> bool {
|
||||||
// will check if the state can stay as it is.
|
// will check if the state can stay as it is.
|
||||||
// p2pool and xmrig are alive if ready and running (syncing is not alive).
|
// p2pool and xmrig are alive if ready and running (syncing is not alive).
|
||||||
let state = lock!(process).state;
|
let state = lock!(process).state;
|
||||||
|
@ -536,7 +546,18 @@ async fn check_state_outcauses_xvb(
|
||||||
let xp_is_alive = lock!(process_xp).state == ProcessState::Alive;
|
let xp_is_alive = lock!(process_xp).state == ProcessState::Alive;
|
||||||
let msg_xmrig_or_proxy = if xp_is_alive { "Xmrig-Proxy" } else { "Xmrig" };
|
let msg_xmrig_or_proxy = if xp_is_alive { "Xmrig-Proxy" } else { "Xmrig" };
|
||||||
// if state is not alive, the algo should stop if it was running and p2pool should be used by xmrig.
|
// if state is not alive, the algo should stop if it was running and p2pool should be used by xmrig.
|
||||||
|
|
||||||
if let Some(handle) = lock!(handle_algo).as_ref() {
|
if let Some(handle) = lock!(handle_algo).as_ref() {
|
||||||
|
// XvB should stop the algo if the state of xp is different from the start.
|
||||||
|
if xp_is_alive != xp_start_alive && !handle.is_finished() {
|
||||||
|
warn!("XvB Process | stop the algorithm because Xmrig-Proxy state changed");
|
||||||
|
output_console(
|
||||||
|
&mut lock!(gui_api).output,
|
||||||
|
"Algorithm stopped because Xmrig-Proxy state changed",
|
||||||
|
ProcessName::Xvb,
|
||||||
|
);
|
||||||
|
handle.abort();
|
||||||
|
}
|
||||||
if state != ProcessState::Alive && !handle.is_finished() {
|
if state != ProcessState::Alive && !handle.is_finished() {
|
||||||
handle.abort();
|
handle.abort();
|
||||||
output_console(
|
output_console(
|
||||||
|
@ -596,6 +617,12 @@ async fn check_state_outcauses_xvb(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if state of Xmrig-Proxy changed, go back to first loop
|
||||||
|
if xp_start_alive != xp_is_alive {
|
||||||
|
*first_loop = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let is_xmrig_alive = lock!(process_xp).state == ProcessState::Alive
|
let is_xmrig_alive = lock!(process_xp).state == ProcessState::Alive
|
||||||
|| lock!(process_xmrig).state == ProcessState::Alive;
|
|| lock!(process_xmrig).state == ProcessState::Alive;
|
||||||
let is_p2pool_alive = lock!(process_p2pool).state == ProcessState::Alive;
|
let is_p2pool_alive = lock!(process_p2pool).state == ProcessState::Alive;
|
||||||
|
@ -645,6 +672,7 @@ async fn check_state_outcauses_xvb(
|
||||||
// nothing to do, we don't want to change other state
|
// nothing to do, we don't want to change other state
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
false
|
||||||
}
|
}
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn signal_interrupt(
|
fn signal_interrupt(
|
||||||
|
|
|
@ -132,7 +132,10 @@ impl XvbPrivStats {
|
||||||
);
|
);
|
||||||
output_console(
|
output_console(
|
||||||
&mut lock!(gui_api).output,
|
&mut lock!(gui_api).output,
|
||||||
&format!("Failure to retrieve private stats from {}", XVB_URL),
|
&format!(
|
||||||
|
"Failure to retrieve private stats from {} because of this error: {}",
|
||||||
|
XVB_URL, err
|
||||||
|
),
|
||||||
ProcessName::Xvb,
|
ProcessName::Xvb,
|
||||||
);
|
);
|
||||||
lock!(process).state = ProcessState::Retry;
|
lock!(process).state = ProcessState::Retry;
|
||||||
|
|
Loading…
Reference in a new issue