mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-24 06:05:51 +00:00
p2pool/app: add STDIN + clear at 56million bytes, 4:3 default ratio
This commit is contained in:
parent
05437720a2
commit
33089ddca3
5 changed files with 54 additions and 16 deletions
|
@ -20,14 +20,14 @@ pub const P2POOL_VERSION: &str = "v2.4";
|
||||||
pub const XMRIG_VERSION: &str = "v6.18.0";
|
pub const XMRIG_VERSION: &str = "v6.18.0";
|
||||||
pub const COMMIT: &str = include_str!("../.git/refs/heads/main");
|
pub const COMMIT: &str = include_str!("../.git/refs/heads/main");
|
||||||
|
|
||||||
// App frame resolution, [16:10] aspect ratio, height = width * 1.6
|
// App frame resolution, [4:3] aspect ratio, [1.33:1]
|
||||||
pub const APP_MIN_WIDTH: f32 = 768.0;
|
pub const APP_MIN_WIDTH: f32 = 640.0;
|
||||||
pub const APP_MIN_HEIGHT: f32 = 480.0;
|
pub const APP_MIN_HEIGHT: f32 = 480.0;
|
||||||
pub const APP_MAX_WIDTH: f32 = 3456.0;
|
pub const APP_MAX_WIDTH: f32 = 2560.0;
|
||||||
pub const APP_MAX_HEIGHT: f32 = 2160.0;
|
pub const APP_MAX_HEIGHT: f32 = 1920.0;
|
||||||
// Default, 1280x800
|
// Default, 1280x960
|
||||||
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
|
pub const APP_DEFAULT_WIDTH: f32 = 1280.0;
|
||||||
pub const APP_DEFAULT_HEIGHT: f32 = 800.0;
|
pub const APP_DEFAULT_HEIGHT: f32 = 960.0;
|
||||||
|
|
||||||
// Use macOS shaped icon for macOS
|
// Use macOS shaped icon for macOS
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
use crate::State;
|
use crate::State;
|
||||||
use egui::{
|
use egui::{
|
||||||
|
TextEdit,
|
||||||
TextStyle::Monospace,
|
TextStyle::Monospace,
|
||||||
Checkbox,ProgressBar,Spinner,Button,Label,Slider,
|
Checkbox,ProgressBar,Spinner,Button,Label,Slider,
|
||||||
SelectableLabel,
|
SelectableLabel,
|
||||||
|
@ -130,7 +131,7 @@ impl Gupax {
|
||||||
// P2Pool/XMRig binary path selection
|
// P2Pool/XMRig binary path selection
|
||||||
ui.add_space(SPACE);
|
ui.add_space(SPACE);
|
||||||
ui.style_mut().override_text_style = Some(Monospace);
|
ui.style_mut().override_text_style = Some(Monospace);
|
||||||
let height = height/20.0;
|
let height = height/28.0;
|
||||||
let text_edit = (ui.available_width()/10.0)-SPACE;
|
let text_edit = (ui.available_width()/10.0)-SPACE;
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if self.p2pool_path.is_empty() {
|
if self.p2pool_path.is_empty() {
|
||||||
|
@ -152,7 +153,7 @@ impl Gupax {
|
||||||
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
||||||
Self::spawn_file_window_thread(file_window, FileType::P2pool);
|
Self::spawn_file_window_thread(file_window, FileType::P2pool);
|
||||||
}
|
}
|
||||||
ui.text_edit_singleline(&mut self.p2pool_path).on_hover_text(GUPAX_PATH_P2POOL);
|
ui.add_sized([ui.available_width()-SPACE, height], TextEdit::hint_text(TextEdit::singleline(&mut self.p2pool_path), GUPAX_PATH_P2POOL));
|
||||||
});
|
});
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if self.xmrig_path.is_empty() {
|
if self.xmrig_path.is_empty() {
|
||||||
|
@ -174,7 +175,7 @@ impl Gupax {
|
||||||
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
||||||
Self::spawn_file_window_thread(file_window, FileType::Xmrig);
|
Self::spawn_file_window_thread(file_window, FileType::Xmrig);
|
||||||
}
|
}
|
||||||
ui.text_edit_singleline(&mut self.xmrig_path).on_hover_text(GUPAX_PATH_XMRIG);
|
ui.add_sized([ui.available_width()-SPACE, height], TextEdit::hint_text(TextEdit::singleline(&mut self.xmrig_path), GUPAX_PATH_XMRIG));
|
||||||
});
|
});
|
||||||
let mut guard = file_window.lock().unwrap();
|
let mut guard = file_window.lock().unwrap();
|
||||||
if guard.picked_p2pool { self.p2pool_path = guard.p2pool_path.clone(); guard.picked_p2pool = false; }
|
if guard.picked_p2pool { self.p2pool_path = guard.p2pool_path.clone(); guard.picked_p2pool = false; }
|
||||||
|
|
|
@ -205,6 +205,23 @@ impl Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset output if larger than 55_999_000 bytes (around 1 week of logs).
|
||||||
|
// The actual [String] holds 56_000_000, but this allows for some leeway so it doesn't allocate more memory.
|
||||||
|
// This will also append a message showing it was reset.
|
||||||
|
fn check_reset_output(output: &Arc<Mutex<String>>, name: ProcessName) {
|
||||||
|
let mut output = output.lock().unwrap();
|
||||||
|
if output.len() > 55_999_000 {
|
||||||
|
let name = match name {
|
||||||
|
ProcessName::P2pool => "P2Pool",
|
||||||
|
ProcessName::Xmrig => "XMRig",
|
||||||
|
};
|
||||||
|
info!("{} | Output is nearing 56,000,000 bytes, resetting!", name);
|
||||||
|
let text = format!("{}\n{} logs are exceeding the maximum: 56,000,000 bytes!\nI've reset the logs for you, your stats may now be inaccurate since they depend on these logs!\nI think you rather have that than have it hogging your memory, though!\n{}", HORI_CONSOLE, name, HORI_CONSOLE);
|
||||||
|
output.clear();
|
||||||
|
output.push_str(&text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- P2Pool specific
|
//---------------------------------------------------------------------------------------------------- P2Pool specific
|
||||||
// Read P2Pool's API file.
|
// Read P2Pool's API file.
|
||||||
fn read_p2pool_api(path: &std::path::PathBuf) -> Result<String, std::io::Error> {
|
fn read_p2pool_api(path: &std::path::PathBuf) -> Result<String, std::io::Error> {
|
||||||
|
@ -419,6 +436,7 @@ impl Helper {
|
||||||
writeln!(pub_api.lock().unwrap().output, "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE);
|
writeln!(pub_api.lock().unwrap().output, "{}\nP2Pool stopped | Uptime: [{}] | Exit status: [{}]\n{}\n\n", HORI_CONSOLE, uptime, exit_status, HORI_CONSOLE);
|
||||||
process.lock().unwrap().signal = ProcessSignal::None;
|
process.lock().unwrap().signal = ProcessSignal::None;
|
||||||
break
|
break
|
||||||
|
// Check RESTART
|
||||||
} else if process.lock().unwrap().signal == ProcessSignal::Restart {
|
} else if process.lock().unwrap().signal == ProcessSignal::Restart {
|
||||||
child_pty.lock().unwrap().kill(); // This actually sends a SIGHUP to p2pool (closes the PTY, hangs up on p2pool)
|
child_pty.lock().unwrap().kill(); // This actually sends a SIGHUP to p2pool (closes the PTY, hangs up on p2pool)
|
||||||
// Wait to get the exit status
|
// Wait to get the exit status
|
||||||
|
@ -468,6 +486,9 @@ impl Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if logs need resetting
|
||||||
|
Self::check_reset_output(&output, ProcessName::P2pool);
|
||||||
|
|
||||||
// Sleep (only if 900ms hasn't passed)
|
// Sleep (only if 900ms hasn't passed)
|
||||||
let elapsed = now.elapsed().as_millis();
|
let elapsed = now.elapsed().as_millis();
|
||||||
// Since logic goes off if less than 1000, casting should be safe
|
// Since logic goes off if less than 1000, casting should be safe
|
||||||
|
@ -526,6 +547,7 @@ impl Helper {
|
||||||
pub fn spawn_helper(helper: &Arc<Mutex<Self>>) {
|
pub fn spawn_helper(helper: &Arc<Mutex<Self>>) {
|
||||||
let mut helper = Arc::clone(helper);
|
let mut helper = Arc::clone(helper);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
info!("Helper | Hello from helper thread! Entering loop where I will spend the rest of my days...");
|
||||||
// Begin loop
|
// Begin loop
|
||||||
loop {
|
loop {
|
||||||
// 1. Loop init timestamp
|
// 1. Loop init timestamp
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -111,6 +111,8 @@ pub struct App {
|
||||||
xmrig_api: Arc<Mutex<PubXmrigApi>>, // Public ready-to-print XMRig API made by the "helper" thread
|
xmrig_api: Arc<Mutex<PubXmrigApi>>, // Public ready-to-print XMRig API made by the "helper" thread
|
||||||
p2pool_img: Arc<Mutex<ImgP2pool>>, // A one-time snapshot of what data P2Pool started with
|
p2pool_img: Arc<Mutex<ImgP2pool>>, // A one-time snapshot of what data P2Pool started with
|
||||||
xmrig_img: Arc<Mutex<ImgXmrig>>, // A one-time snapshot of what data XMRig started with
|
xmrig_img: Arc<Mutex<ImgXmrig>>, // A one-time snapshot of what data XMRig started with
|
||||||
|
// Buffer State
|
||||||
|
p2pool_console: String, // The buffer between the p2pool console and the [Helper]
|
||||||
// State from [--flags]
|
// State from [--flags]
|
||||||
no_startup: bool,
|
no_startup: bool,
|
||||||
// Static stuff
|
// Static stuff
|
||||||
|
@ -171,6 +173,7 @@ impl App {
|
||||||
xmrig_api,
|
xmrig_api,
|
||||||
p2pool_img,
|
p2pool_img,
|
||||||
xmrig_img,
|
xmrig_img,
|
||||||
|
p2pool_console: String::with_capacity(10),
|
||||||
resizing: false,
|
resizing: false,
|
||||||
alpha: 0,
|
alpha: 0,
|
||||||
no_startup: false,
|
no_startup: false,
|
||||||
|
@ -320,6 +323,12 @@ impl App {
|
||||||
app.tab = app.state.gupax.tab;
|
app.tab = app.state.gupax.tab;
|
||||||
drop(og); // Unlock [og]
|
drop(og); // Unlock [og]
|
||||||
info!("App ... OK");
|
info!("App ... OK");
|
||||||
|
|
||||||
|
// Spawn the "Helper" thread.
|
||||||
|
info!("Helper | Spawning helper thread...");
|
||||||
|
Helper::spawn_helper(&app.helper);
|
||||||
|
info!("Helper ... OK");
|
||||||
|
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1126,7 +1135,7 @@ impl eframe::App for App {
|
||||||
Gupax::show(&mut self.state.gupax, &self.og, &self.state_path, &self.update, &self.file_window, &mut self.error_state, &self.restart, self.width, self.height, frame, ctx, ui);
|
Gupax::show(&mut self.state.gupax, &self.og, &self.state_path, &self.update, &self.file_window, &mut self.error_state, &self.restart, self.width, self.height, frame, ctx, ui);
|
||||||
}
|
}
|
||||||
Tab::P2pool => {
|
Tab::P2pool => {
|
||||||
P2pool::show(&mut self.state.p2pool, &mut self.node_vec, &self.og, &self.ping, &self.regex, &self.helper, &self.p2pool_api, self.width, self.height, ctx, ui);
|
P2pool::show(&mut self.state.p2pool, &mut self.node_vec, &self.og, &self.ping, &self.regex, &self.p2pool, &self.p2pool_api, &mut self.p2pool_console, self.width, self.height, ctx, ui);
|
||||||
}
|
}
|
||||||
Tab::Xmrig => {
|
Tab::Xmrig => {
|
||||||
Xmrig::show(&mut self.state.xmrig, &mut self.pool_vec, &self.regex, self.width, self.height, ctx, ui);
|
Xmrig::show(&mut self.state.xmrig, &mut self.pool_vec, &self.regex, self.width, self.height, ctx, ui);
|
||||||
|
|
|
@ -32,8 +32,8 @@ use regex::Regex;
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
||||||
impl P2pool {
|
impl P2pool {
|
||||||
pub fn show(&mut self, node_vec: &mut Vec<(String, Node)>, og: &Arc<Mutex<State>>, ping: &Arc<Mutex<Ping>>, regex: &Regexes, helper: &Arc<Mutex<Helper>>, api: &Arc<Mutex<PubP2poolApi>>, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
pub fn show(&mut self, node_vec: &mut Vec<(String, Node)>, og: &Arc<Mutex<State>>, ping: &Arc<Mutex<Ping>>, regex: &Regexes, process: &Arc<Mutex<Process>>, api: &Arc<Mutex<PubP2poolApi>>, buffer: &mut String, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||||
let text_edit = height / 22.0;
|
let text_edit = height / 25.0;
|
||||||
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
//---------------------------------------------------------------------------------------------------- [Simple] Console
|
||||||
if self.simple {
|
if self.simple {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
|
@ -51,7 +51,7 @@ impl P2pool {
|
||||||
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
//---------------------------------------------------------------------------------------------------- [Advanced] Console
|
||||||
} else {
|
} else {
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
let height = height / 3.0;
|
let height = height / 2.8;
|
||||||
let width = width - SPACE;
|
let width = width - SPACE;
|
||||||
ui.style_mut().override_text_style = Some(Monospace);
|
ui.style_mut().override_text_style = Some(Monospace);
|
||||||
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
egui::Frame::none().fill(DARK_GRAY).show(ui, |ui| {
|
||||||
|
@ -61,7 +61,14 @@ impl P2pool {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.add_sized([width, text_edit], TextEdit::hint_text(TextEdit::singleline(&mut "".to_string()), r#"Type a command (e.g "help" or "status") and press Enter"#));
|
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"#));
|
||||||
|
// If the user pressed enter, dump buffer contents into the process STDIN
|
||||||
|
if response.lost_focus() && ui.input().key_pressed(egui::Key::Enter) {
|
||||||
|
response.request_focus(); // Get focus back
|
||||||
|
let mut buffer = std::mem::take(buffer); // Take buffer
|
||||||
|
let mut process = process.lock().unwrap(); // Lock
|
||||||
|
if process.is_alive() { process.input.push(buffer); } // Push only if alive
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +421,7 @@ impl P2pool {
|
||||||
|
|
||||||
// [Main/Mini]
|
// [Main/Mini]
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let height = height/3.0;
|
let height = height/4.0;
|
||||||
ui.group(|ui| { ui.horizontal(|ui| {
|
ui.group(|ui| { ui.horizontal(|ui| {
|
||||||
let width = (width/4.0)-SPACE;
|
let width = (width/4.0)-SPACE;
|
||||||
let height = height + 6.0;
|
let height = height + 6.0;
|
||||||
|
@ -429,7 +436,6 @@ impl P2pool {
|
||||||
ui.style_mut().spacing.slider_width = width/1.2;
|
ui.style_mut().spacing.slider_width = width/1.2;
|
||||||
ui.style_mut().spacing.interact_size.y = height;
|
ui.style_mut().spacing.interact_size.y = height;
|
||||||
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
|
ui.style_mut().override_text_style = Some(Name("MonospaceSmall".into()));
|
||||||
// ui.style_mut().override_text_style = Some(Monospace);
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_sized([text, height], Label::new("Out peers [10-450]:"));
|
ui.add_sized([text, height], Label::new("Out peers [10-450]:"));
|
||||||
ui.add_sized([width, height], Slider::new(&mut self.out_peers, 10..=450)).on_hover_text(P2POOL_OUT);
|
ui.add_sized([width, height], Slider::new(&mut self.out_peers, 10..=450)).on_hover_text(P2POOL_OUT);
|
||||||
|
|
Loading…
Reference in a new issue