feat: use rust edition 2024, apply fmt 2024
Some checks failed
Lockbud / lockbud (push) Waiting to run
Rust / fmt (push) Waiting to run
Rust / test (push) Waiting to run
Rust / clippy (macos-latest) (push) Waiting to run
Rust / clippy (ubuntu-latest) (push) Waiting to run
Rust / check (macos-latest) (push) Waiting to run
Rust / check (ubuntu-latest) (push) Waiting to run
Rust / doc (push) Waiting to run
Typo / typo (push) Waiting to run
Audit / audit (push) Has been cancelled

This commit is contained in:
Cyrix126 2024-11-19 22:13:33 +01:00
parent fd4e62342e
commit 0ea492d930
39 changed files with 259 additions and 196 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
/target /target
/ra_target
/feature /feature
.DS_Store .DS_Store
rustc-ice-* rustc-ice-*

View file

@ -1,11 +1,11 @@
cargo-features = ["profile-rustflags", "codegen-backend"] cargo-features = ["profile-rustflags", "codegen-backend", "edition2024"]
[package] [package]
name = "gupaxx" name = "gupaxx"
version = "1.5.3" version = "1.5.3"
authors = ["cyrix126 <gupaxx@baermail.fr>"] authors = ["cyrix126 <gupaxx@baermail.fr>"]
description = "Fork of Gupax integrating the XMRvsBeast Raffle " description = "Fork of Gupax integrating the XMRvsBeast Raffle "
documentation = "https://github.com/cyrix126/gupaxx" documentation = "https://github.com/cyrix126/gupaxx"
edition = "2021" edition = "2024"
[profile.release] [profile.release]
panic = "abort" panic = "abort"
@ -16,7 +16,8 @@ strip = "symbols"
rustflags = ["-Zlocation-detail=none"] rustflags = ["-Zlocation-detail=none"]
[profile.dev] [profile.dev]
codegen-backend = "cranelift" # can induce issue when using rust-analyzer, but allows smaller dev build time
# codegen-backend = "cranelift"
[features] [features]
default = [] default = []

View file

@ -2,7 +2,7 @@ use std::sync::{Arc, Mutex};
use super::App; use super::App;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
use crate::errors::{process_running, ErrorButtons, ErrorFerris}; use crate::errors::{ErrorButtons, ErrorFerris, process_running};
use crate::helper::{Helper, ProcessName, ProcessState}; use crate::helper::{Helper, ProcessName, ProcessState};
use crate::inits::init_text_styles; use crate::inits::init_text_styles;
use crate::{NODE_MIDDLE, P2POOL_MIDDLE, SECOND, XMRIG_MIDDLE, XMRIG_PROXY_MIDDLE, XVB_MIDDLE}; use crate::{NODE_MIDDLE, P2POOL_MIDDLE, SECOND, XMRIG_MIDDLE, XMRIG_PROXY_MIDDLE, XVB_MIDDLE};

View file

@ -1,9 +1,13 @@
use crate::cli::parse_args; use crate::APP_DEFAULT_HEIGHT;
use crate::APP_DEFAULT_WIDTH;
use crate::GUPAX_VERSION;
use crate::OS;
use crate::cli::Cli; use crate::cli::Cli;
use crate::cli::parse_args;
use crate::components::gupax::FileWindow; use crate::components::gupax::FileWindow;
use crate::components::node::Ping; use crate::components::node::Ping;
use crate::components::node::RemoteNode;
use crate::components::node::REMOTE_NODES; use crate::components::node::REMOTE_NODES;
use crate::components::node::RemoteNode;
use crate::components::update::Update; use crate::components::update::Update;
use crate::disk::consts::NODE_TOML; use crate::disk::consts::NODE_TOML;
use crate::disk::consts::POOL_TOML; use crate::disk::consts::POOL_TOML;
@ -16,18 +20,18 @@ use crate::disk::state::State;
use crate::errors::ErrorButtons; use crate::errors::ErrorButtons;
use crate::errors::ErrorFerris; use crate::errors::ErrorFerris;
use crate::errors::ErrorState; use crate::errors::ErrorState;
use crate::helper::Helper;
use crate::helper::Process;
use crate::helper::ProcessName;
use crate::helper::Sys;
use crate::helper::node::PubNodeApi; use crate::helper::node::PubNodeApi;
use crate::helper::p2pool::ImgP2pool; use crate::helper::p2pool::ImgP2pool;
use crate::helper::p2pool::PubP2poolApi; use crate::helper::p2pool::PubP2poolApi;
use crate::helper::xrig::xmrig::ImgXmrig; use crate::helper::xrig::xmrig::ImgXmrig;
use crate::helper::xrig::xmrig::PubXmrigApi; use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::priv_stats::RuntimeMode;
use crate::helper::xvb::PubXvbApi; use crate::helper::xvb::PubXvbApi;
use crate::helper::Helper; use crate::helper::xvb::priv_stats::RuntimeMode;
use crate::helper::Process;
use crate::helper::ProcessName;
use crate::helper::Sys;
use crate::inits::init_text_styles; use crate::inits::init_text_styles;
use crate::miscs::cmp_f64; use crate::miscs::cmp_f64;
use crate::miscs::get_exe; use crate::miscs::get_exe;
@ -35,14 +39,10 @@ use crate::miscs::get_exe_dir;
use crate::utils::constants::VISUALS; use crate::utils::constants::VISUALS;
use crate::utils::macros::arc_mut; use crate::utils::macros::arc_mut;
use crate::utils::sudo::SudoState; use crate::utils::sudo::SudoState;
use crate::APP_DEFAULT_HEIGHT;
use crate::APP_DEFAULT_WIDTH;
use crate::GUPAX_VERSION;
use crate::OS;
use derive_more::derive::Display; use derive_more::derive::Display;
use eframe::CreationContext; use eframe::CreationContext;
use egui::vec2;
use egui::Vec2; use egui::Vec2;
use egui::vec2;
use log::debug; use log::debug;
use log::error; use log::error;
use log::info; use log::info;

View file

@ -1,7 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use crate::app::eframe_impl::{ProcessStateGui, ProcessStatesGui}; use crate::app::eframe_impl::{ProcessStateGui, ProcessStatesGui};
use crate::app::{keys::KeyPressed, Restart}; use crate::app::{Restart, keys::KeyPressed};
use crate::disk::node::Node; use crate::disk::node::Node;
use crate::disk::pool::Pool; use crate::disk::pool::Pool;
use crate::disk::state::{Gupax, State}; use crate::disk::state::{Gupax, State};
@ -583,7 +583,9 @@ impl crate::app::App {
}; };
// check path of binary except for XvB // check path of binary except for XvB
if name != ProcessName::Xvb && !crate::components::update::check_binary_path(path, name) { if name != ProcessName::Xvb && !crate::components::update::check_binary_path(path, name) {
let msg_error = format!("{name} binary at the given PATH in the Gupaxx tab doesn't look like {name}! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where {name} is located."); let msg_error = format!(
"{name} binary at the given PATH in the Gupaxx tab doesn't look like {name}! To fix: goto the [Gupaxx Advanced] tab, select [Open] and specify where {name} is located."
);
return Err(msg_error); return Err(msg_error);
} }

View file

@ -1,9 +1,9 @@
use crate::app::panels::middle::*;
use crate::app::ErrorState; use crate::app::ErrorState;
use crate::app::Restart; use crate::app::Restart;
use crate::app::panels::middle::*;
use crate::components::gupax::*; use crate::components::gupax::*;
use crate::components::update::check_binary_path;
use crate::components::update::Update; use crate::components::update::Update;
use crate::components::update::check_binary_path;
use crate::disk::state::*; use crate::disk::state::*;
use log::debug; use log::debug;
use std::path::Path; use std::path::Path;

View file

@ -1,6 +1,6 @@
use crate::app::Tab;
use crate::app::eframe_impl::ProcessStatesGui; use crate::app::eframe_impl::ProcessStatesGui;
use crate::app::keys::KeyPressed; use crate::app::keys::KeyPressed;
use crate::app::Tab;
use crate::helper::ProcessName; use crate::helper::ProcessName;
use crate::utils::constants::*; use crate::utils::constants::*;
use crate::utils::errors::{ErrorButtons, ErrorFerris}; use crate::utils::errors::{ErrorButtons, ErrorFerris};

View file

@ -11,9 +11,9 @@ use log::debug;
use crate::components::gupax::{FileType, FileWindow}; use crate::components::gupax::{FileType, FileWindow};
use crate::disk::state::{Gupax, Node}; use crate::disk::state::{Gupax, Node};
use crate::helper::node::PubNodeApi;
use crate::helper::Process; use crate::helper::Process;
use crate::regex::{num_lines, REGEXES}; use crate::helper::node::PubNodeApi;
use crate::regex::{REGEXES, num_lines};
use crate::utils::constants::DARK_GRAY; use crate::utils::constants::DARK_GRAY;
use crate::{GREEN, LIGHT_GRAY, P2POOL_IN, P2POOL_LOG, P2POOL_OUT, RED, SPACE}; use crate::{GREEN, LIGHT_GRAY, P2POOL_IN, P2POOL_LOG, P2POOL_OUT, RED, SPACE};

View file

@ -19,7 +19,7 @@ use crate::regex::num_lines;
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::{components::node::*, constants::*, helper::*, utils::regex::Regexes}; use crate::{components::node::*, constants::*, helper::*, utils::regex::Regexes};
use egui::{vec2, Color32, Label, RichText, TextEdit, TextStyle, Vec2}; use egui::{Color32, Label, RichText, TextEdit, TextStyle, Vec2, vec2};
use log::*; use log::*;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View file

@ -4,15 +4,15 @@ use std::sync::Mutex;
use crate::app::panels::middle::Hyperlink; use crate::app::panels::middle::Hyperlink;
use crate::app::panels::middle::ProgressBar; use crate::app::panels::middle::ProgressBar;
use crate::app::panels::middle::Spinner; use crate::app::panels::middle::Spinner;
use crate::components::node::format_ip_location;
use crate::components::node::format_ms;
use crate::components::node::Ping; use crate::components::node::Ping;
use crate::components::node::RemoteNode; use crate::components::node::RemoteNode;
use crate::components::node::format_ip_location;
use crate::components::node::format_ms;
use crate::disk::state::P2pool; use crate::disk::state::P2pool;
use egui::vec2;
use egui::Button; use egui::Button;
use egui::Checkbox; use egui::Checkbox;
use egui::Vec2; use egui::Vec2;
use egui::vec2;
use crate::constants::*; use crate::constants::*;
use egui::{Color32, ComboBox, Label, RichText, Ui}; use egui::{Color32, ComboBox, Label, RichText, Ui};

View file

@ -18,9 +18,10 @@
use egui::Vec2; use egui::Vec2;
use crate::{ use crate::{
app::{eframe_impl::ProcessStatesGui, Benchmark}, app::{Benchmark, eframe_impl::ProcessStatesGui},
disk::{gupax_p2pool_api::GupaxP2poolApi, state::Status, status::*}, disk::{gupax_p2pool_api::GupaxP2poolApi, state::Status, status::*},
helper::{ helper::{
ProcessName, Sys,
node::PubNodeApi, node::PubNodeApi,
p2pool::{ImgP2pool, PubP2poolApi}, p2pool::{ImgP2pool, PubP2poolApi},
xrig::{ xrig::{
@ -28,7 +29,6 @@ use crate::{
xmrig_proxy::PubXmrigProxyApi, xmrig_proxy::PubXmrigProxyApi,
}, },
xvb::PubXvbApi, xvb::PubXvbApi,
ProcessName, Sys,
}, },
}; };
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};

View file

@ -8,7 +8,7 @@ use crate::helper::node::PubNodeApi;
use crate::helper::p2pool::{ImgP2pool, PubP2poolApi}; use crate::helper::p2pool::{ImgP2pool, PubP2poolApi};
use crate::helper::xrig::xmrig::{ImgXmrig, PubXmrigApi}; use crate::helper::xrig::xmrig::{ImgXmrig, PubXmrigApi};
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::{rounds::XvbRound, PubXvbApi}; use crate::helper::xvb::{PubXvbApi, rounds::XvbRound};
use crate::helper::{ProcessName, Sys}; use crate::helper::{ProcessName, Sys};
use crate::constants::*; use crate::constants::*;

View file

@ -18,13 +18,13 @@
use crate::constants::*; use crate::constants::*;
use crate::disk::pool::Pool; use crate::disk::pool::Pool;
use crate::disk::state::Xmrig; use crate::disk::state::Xmrig;
use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::helper::Process; use crate::helper::Process;
use crate::regex::{num_lines, REGEXES}; use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::regex::{REGEXES, num_lines};
use crate::utils::regex::Regexes; use crate::utils::regex::Regexes;
use egui::{ use egui::{
vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, Slider, TextEdit, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, Slider, TextEdit, TextStyle,
TextStyle, Vec2, Vec2, vec2,
}; };
use log::*; use log::*;

View file

@ -1,5 +1,5 @@
use egui::{ use egui::{
vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, TextEdit, TextStyle, Vec2, Button, Checkbox, ComboBox, Label, RichText, SelectableLabel, TextEdit, TextStyle, Vec2, vec2,
}; };
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@ -7,9 +7,9 @@ use log::{debug, info};
use crate::disk::pool::Pool; use crate::disk::pool::Pool;
use crate::disk::state::XmrigProxy; use crate::disk::state::XmrigProxy;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::Process; use crate::helper::Process;
use crate::regex::{num_lines, REGEXES}; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::regex::{REGEXES, num_lines};
use crate::utils::constants::DARK_GRAY; use crate::utils::constants::DARK_GRAY;
use crate::{ use crate::{
GREEN, LIGHT_GRAY, LIST_ADD, LIST_CLEAR, LIST_DELETE, LIST_SAVE, RED, SPACE, XMRIG_API_IP, GREEN, LIGHT_GRAY, LIST_ADD, LIST_CLEAR, LIST_DELETE, LIST_SAVE, RED, SPACE, XMRIG_API_IP,

View file

@ -1,15 +1,16 @@
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use egui::{vec2, Image, RichText, TextEdit, TextStyle, Ui, Vec2}; use egui::{Image, RichText, TextEdit, TextStyle, Ui, Vec2, vec2};
use log::debug; use log::debug;
use readable::num::Float; use readable::num::Float;
use readable::up::Uptime; use readable::up::Uptime;
use crate::XVB_MINING_ON_FIELD;
use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode}; use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode};
use crate::helper::xrig::xmrig::PubXmrigApi; use crate::helper::xrig::xmrig::PubXmrigApi;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::priv_stats::RuntimeMode;
use crate::helper::xvb::PubXvbApi; use crate::helper::xvb::PubXvbApi;
use crate::helper::xvb::priv_stats::RuntimeMode;
use crate::regex::num_lines; use crate::regex::num_lines;
use crate::utils::constants::{ use crate::utils::constants::{
GREEN, LIGHT_GRAY, ORANGE, RED, XVB_DONATED_1H_FIELD, XVB_DONATED_24H_FIELD, GREEN, LIGHT_GRAY, ORANGE, RED, XVB_DONATED_1H_FIELD, XVB_DONATED_24H_FIELD,
@ -21,7 +22,6 @@ use crate::utils::constants::{
XVB_TOKEN_LEN, XVB_URL_RULES, XVB_WINNER_FIELD, XVB_TOKEN_LEN, XVB_URL_RULES, XVB_WINNER_FIELD,
}; };
use crate::utils::regex::Regexes; use crate::utils::regex::Regexes;
use crate::XVB_MINING_ON_FIELD;
use crate::{ use crate::{
constants::{BYTES_XVB, SPACE}, constants::{BYTES_XVB, SPACE},
utils::constants::{DARK_GRAY, XVB_URL}, utils::constants::{DARK_GRAY, XVB_URL},

View file

@ -1,9 +1,9 @@
use clap::Parser;
use clap::Subcommand;
use clap::crate_authors; use clap::crate_authors;
use clap::crate_description; use clap::crate_description;
use clap::crate_name; use clap::crate_name;
use clap::crate_version; use clap::crate_version;
use clap::Parser;
use clap::Subcommand;
use log::debug; use log::debug;
use log::info; use log::info;
use log::warn; use log::warn;

View file

@ -19,7 +19,7 @@ use crate::components::update::get_user_agent;
use crate::{constants::*, macros::*}; use crate::{constants::*, macros::*};
use egui::Color32; use egui::Color32;
use log::*; use log::*;
use rand::{thread_rng, Rng}; use rand::{Rng, thread_rng};
use reqwest::{Client, RequestBuilder}; use reqwest::{Client, RequestBuilder};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -467,7 +467,7 @@ mod test {
use log::error; use log::error;
use reqwest::Client; use reqwest::Client;
use crate::components::node::{format_ip, REMOTE_NODES, REMOTE_NODE_LENGTH}; use crate::components::node::{REMOTE_NODE_LENGTH, REMOTE_NODES, format_ip};
use crate::components::update::get_user_agent; use crate::components::update::get_user_agent;
// Iterate through all nodes, find the longest domain. // Iterate through all nodes, find the longest domain.
pub const REMOTE_NODE_MAX_CHARS: usize = { pub const REMOTE_NODE_MAX_CHARS: usize = {

View file

@ -33,10 +33,10 @@ use crate::{
miscs::get_exe_dir, miscs::get_exe_dir,
utils::errors::{ErrorButtons, ErrorFerris, ErrorState}, utils::errors::{ErrorButtons, ErrorFerris, ErrorState},
}; };
use anyhow::{anyhow, Error}; use anyhow::{Error, anyhow};
use log::*; use log::*;
use rand::distributions::Alphanumeric; use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng}; use rand::{Rng, thread_rng};
use reqwest::header::{LOCATION, USER_AGENT}; use reqwest::header::{LOCATION, USER_AGENT};
use reqwest::{Client, RequestBuilder}; use reqwest::{Client, RequestBuilder};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -130,8 +130,7 @@ const MSG_DOWNLOAD: &str = "Downloading packages";
const MSG_EXTRACT: &str = "Extracting packages"; const MSG_EXTRACT: &str = "Extracting packages";
const MSG_UPGRADE: &str = "Upgrading packages"; const MSG_UPGRADE: &str = "Upgrading packages";
pub const MSG_FAILED: &str = "Update failed"; pub const MSG_FAILED: &str = "Update failed";
pub const MSG_FAILED_HELP: &str = pub const MSG_FAILED_HELP: &str = "Consider manually replacing your executable from github releases: https://github.com/Cyrix126/gupaxx/releases";
"Consider manually replacing your executable from github releases: https://github.com/Cyrix126/gupaxx/releases";
const INIT: &str = "------------------- Init -------------------"; const INIT: &str = "------------------- Init -------------------";
const METADATA: &str = "----------------- Metadata -----------------"; const METADATA: &str = "----------------- Metadata -----------------";
const COMPARE: &str = "----------------- Compare ------------------"; const COMPARE: &str = "----------------- Compare ------------------";

View file

@ -32,8 +32,8 @@
use crate::disk::consts::*; use crate::disk::consts::*;
use crate::{app::Tab, components::gupax::Ratio, constants::*, human::*, macros::*, xmr::*}; use crate::{app::Tab, components::gupax::Ratio, constants::*, human::*, macros::*, xmr::*};
use figment::providers::{Format, Toml};
use figment::Figment; use figment::Figment;
use figment::providers::{Format, Toml};
use log::*; use log::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]

View file

@ -1,5 +1,5 @@
use anyhow::Result; use anyhow::Result;
use rand::{distributions::Alphanumeric, thread_rng, Rng}; use rand::{Rng, distributions::Alphanumeric, thread_rng};
use super::*; use super::*;
use crate::{components::node::RemoteNode, disk::status::*}; use crate::{components::node::RemoteNode, disk::status::*};

View file

@ -327,9 +327,10 @@ mod test {
assert_eq!(api.payout_u64, 1); assert_eq!(api.payout_u64, 1);
assert_eq!(api.xmr.to_u64(), 2); assert_eq!(api.xmr.to_u64(), 2);
assert!(!api.payout_ord.is_empty()); assert!(!api.payout_ord.is_empty());
assert!(api assert!(
.log api.log
.contains("2022-01-27 01:30:23.1377 | 0.000000000001 XMR | Block 2,642,816")); .contains("2022-01-27 01:30:23.1377 | 0.000000000001 XMR | Block 2,642,816")
);
} }
#[test] #[test]

View file

@ -56,7 +56,7 @@ use std::{
}; };
use strum::EnumIter; use strum::EnumIter;
use self::xvb::{nodes::XvbNode, PubXvbApi}; use self::xvb::{PubXvbApi, nodes::XvbNode};
pub mod node; pub mod node;
pub mod p2pool; pub mod p2pool;
pub mod tests; pub mod tests;
@ -339,7 +339,10 @@ impl Helper {
"{} Watchdog | Output is nearing {} bytes, resetting!", "{} Watchdog | Output is nearing {} bytes, resetting!",
name, MAX_GUI_OUTPUT_BYTES name, MAX_GUI_OUTPUT_BYTES
); );
let text = format!("{}\n{} GUI log is exceeding the maximum: {} bytes!\nI've reset the logs for you!\n{}\n\n\n\n", HORI_CONSOLE, name, MAX_GUI_OUTPUT_BYTES, HORI_CONSOLE); let text = format!(
"{}\n{} GUI log is exceeding the maximum: {} bytes!\nI've reset the logs for you!\n{}\n\n\n\n",
HORI_CONSOLE, name, MAX_GUI_OUTPUT_BYTES, HORI_CONSOLE
);
output.clear(); output.clear();
output.push_str(&text); output.push_str(&text);
debug!("{} Watchdog | Resetting GUI output ... OK", name); debug!("{} Watchdog | Resetting GUI output ... OK", name);
@ -455,7 +458,9 @@ impl Helper {
let sysinfo_processes = sysinfo::ProcessRefreshKind::new().with_cpu(); let sysinfo_processes = sysinfo::ProcessRefreshKind::new().with_cpu();
thread::spawn(move || { thread::spawn(move || {
info!("Helper | Hello from helper thread! Entering loop where I will spend the rest of my days..."); 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

View file

@ -16,8 +16,8 @@ use tokio::spawn;
use crate::{ use crate::{
disk::state::Node, disk::state::Node,
helper::{ helper::{
check_died, check_user_input, signal_end, sleep_end_loop, ProcessName, ProcessSignal, ProcessName, ProcessSignal, ProcessState, check_died, check_user_input, signal_end,
ProcessState, sleep_end_loop,
}, },
macros::{arc_mut, sleep}, macros::{arc_mut, sleep},
}; };

View file

@ -2,20 +2,20 @@ use super::Helper;
use super::Process; use super::Process;
use crate::components::node::RemoteNode; use crate::components::node::RemoteNode;
use crate::disk::state::P2pool; use crate::disk::state::P2pool;
use crate::helper::ProcessName;
use crate::helper::ProcessSignal;
use crate::helper::ProcessState;
use crate::helper::check_died; use crate::helper::check_died;
use crate::helper::check_user_input; use crate::helper::check_user_input;
use crate::helper::signal_end; use crate::helper::signal_end;
use crate::helper::sleep_end_loop; use crate::helper::sleep_end_loop;
use crate::helper::ProcessName; use crate::regex::P2POOL_REGEX;
use crate::helper::ProcessSignal;
use crate::helper::ProcessState;
use crate::regex::contains_end_status; use crate::regex::contains_end_status;
use crate::regex::contains_statuscommand; use crate::regex::contains_statuscommand;
use crate::regex::contains_yourhashrate; use crate::regex::contains_yourhashrate;
use crate::regex::contains_yourshare; use crate::regex::contains_yourshare;
use crate::regex::estimated_hr; use crate::regex::estimated_hr;
use crate::regex::nb_current_shares; use crate::regex::nb_current_shares;
use crate::regex::P2POOL_REGEX;
use crate::{ use crate::{
constants::*, constants::*,
disk::{gupax_p2pool_api::GupaxP2poolApi, node::Node}, disk::{gupax_p2pool_api::GupaxP2poolApi, node::Node},
@ -99,7 +99,10 @@ impl Helper {
gui_api.lock().unwrap().sidechain_ehr gui_api.lock().unwrap().sidechain_ehr
); );
} else { } else {
error!("P2pool | PTY Getting data from status: Lines contains Your shares but no value found: {}", line); error!(
"P2pool | PTY Getting data from status: Lines contains Your shares but no value found: {}",
line
);
} }
} }
if contains_yourshare(&line) { if contains_yourshare(&line) {
@ -111,7 +114,10 @@ impl Helper {
); );
gui_api.lock().unwrap().sidechain_shares = shares; gui_api.lock().unwrap().sidechain_shares = shares;
} else { } else {
error!("P2pool | PTY Getting data from status: Lines contains Your shares but no value found: {}", line); error!(
"P2pool | PTY Getting data from status: Lines contains Your shares but no value found: {}",
line
);
} }
} }
if contains_end_status(&line) { if contains_end_status(&line) {
@ -204,10 +210,7 @@ impl Helper {
// Print arguments & user settings to console // Print arguments & user settings to console
crate::disk::print_dash(&format!( crate::disk::print_dash(&format!(
"P2Pool | Launch arguments: {:#?} | Local API Path: {:#?} | Network API Path: {:#?} | Pool API Path: {:#?}", "P2Pool | Launch arguments: {:#?} | Local API Path: {:#?} | Network API Path: {:#?} | Pool API Path: {:#?}",
args, args, api_path_local, api_path_network, api_path_pool,
api_path_local,
api_path_network,
api_path_pool,
)); ));
// Spawn watchdog thread // Spawn watchdog thread
@ -914,7 +917,10 @@ impl PubP2poolApi {
xmr_new xmr_new
); );
debug!("P2Pool Watchdog | Total [XMR mined] should be ... {}", xmr); debug!("P2Pool Watchdog | Total [XMR mined] should be ... {}", xmr);
debug!("P2Pool Watchdog | Correct [XMR mined per] should be ... [{}/hour, {}/day, {}/month]", xmr_hour, xmr_day, xmr_month); debug!(
"P2Pool Watchdog | Correct [XMR mined per] should be ... [{}/hour, {}/day, {}/month]",
xmr_hour, xmr_day, xmr_month
);
} }
// 6. Mutate the struct with the new info // 6. Mutate the struct with the new info

View file

@ -4,9 +4,9 @@ mod test {
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::algorithm::Algorithm; use crate::helper::xvb::algorithm::Algorithm;
use crate::helper::{ use crate::helper::{
Helper, Process, ProcessName, ProcessState,
p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi}, p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi},
xvb::{priv_stats::RuntimeDonationLevel, priv_stats::RuntimeMode}, xvb::{priv_stats::RuntimeDonationLevel, priv_stats::RuntimeMode},
Helper, Process, ProcessName, ProcessState,
}; };
use crate::miscs::client; use crate::miscs::client;
@ -241,11 +241,11 @@ Uptime = 0h 2m 4s
#[test] #[test]
fn update_pub_p2pool_from_local_network_pool() { fn update_pub_p2pool_from_local_network_pool() {
use crate::helper::PubP2poolApi;
use crate::helper::p2pool::PoolStatistics; use crate::helper::p2pool::PoolStatistics;
use crate::helper::p2pool::PrivP2poolLocalApi; use crate::helper::p2pool::PrivP2poolLocalApi;
use crate::helper::p2pool::PrivP2poolNetworkApi; use crate::helper::p2pool::PrivP2poolNetworkApi;
use crate::helper::p2pool::PrivP2poolPoolApi; use crate::helper::p2pool::PrivP2poolPoolApi;
use crate::helper::PubP2poolApi;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
let public = Arc::new(Mutex::new(PubP2poolApi::new())); let public = Arc::new(Mutex::new(PubP2poolApi::new()));
let local = PrivP2poolLocalApi { let local = PrivP2poolLocalApi {
@ -338,7 +338,9 @@ Uptime = 0h 2m 4s
println!("{:#?}", process); println!("{:#?}", process);
assert!(process.lock().unwrap().state == ProcessState::NotMining); assert!(process.lock().unwrap().state == ProcessState::NotMining);
let output_parse = Arc::new(Mutex::new(String::from("[2022-02-12 12:49:30.311] net new job from 192.168.2.1:3333 diff 402K algo rx/0 height 2241142 (11 tx)"))); let output_parse = Arc::new(Mutex::new(String::from(
"[2022-02-12 12:49:30.311] net new job from 192.168.2.1:3333 diff 402K algo rx/0 height 2241142 (11 tx)",
)));
PubXmrigApi::update_from_output( PubXmrigApi::update_from_output(
&mut public.lock().unwrap(), &mut public.lock().unwrap(),
&output_parse, &output_parse,
@ -547,7 +549,7 @@ Uptime = 0h 2m 4s
helper::{p2pool::PubP2poolApi, xrig::xmrig::PubXmrigApi}, helper::{p2pool::PubP2poolApi, xrig::xmrig::PubXmrigApi},
}; };
use crate::helper::xvb::{public_stats::XvbPubStats, PubXvbApi}; use crate::helper::xvb::{PubXvbApi, public_stats::XvbPubStats};
use reqwest_middleware::ClientWithMiddleware as Client; use reqwest_middleware::ClientWithMiddleware as Client;
#[test] #[test]

View file

@ -1,6 +1,6 @@
use crate::helper::XvbNode; use crate::helper::XvbNode;
use anyhow::anyhow;
use anyhow::Result; use anyhow::Result;
use anyhow::anyhow;
use log::info; use log::info;
use reqwest::header::AUTHORIZATION; use reqwest::header::AUTHORIZATION;
use reqwest_middleware::ClientWithMiddleware as Client; use reqwest_middleware::ClientWithMiddleware as Client;

View file

@ -1,10 +1,10 @@
use crate::constants::*; use crate::constants::*;
use crate::helper::xrig::update_xmrig_config; use crate::helper::xrig::update_xmrig_config;
use crate::helper::{arc_mut, check_died, check_user_input, sleep, sleep_end_loop, Process};
use crate::helper::{Helper, ProcessName, ProcessSignal, ProcessState}; use crate::helper::{Helper, ProcessName, ProcessSignal, ProcessState};
use crate::helper::{Process, arc_mut, check_died, check_user_input, sleep, sleep_end_loop};
use crate::helper::{PubXvbApi, XvbNode}; use crate::helper::{PubXvbApi, XvbNode};
use crate::miscs::{client, output_console}; use crate::miscs::{client, output_console};
use crate::regex::{contains_error, contains_usepool, detect_new_node_xmrig, XMRIG_REGEX}; use crate::regex::{XMRIG_REGEX, contains_error, contains_usepool, detect_new_node_xmrig};
use crate::utils::human::HumanNumber; use crate::utils::human::HumanNumber;
use crate::utils::sudo::SudoState; use crate::utils::sudo::SudoState;
use enclose::enclose; use enclose::enclose;
@ -555,7 +555,9 @@ impl Helper {
&& !process_xp.lock().unwrap().is_alive() && !process_xp.lock().unwrap().is_alive()
&& process_p2pool.lock().unwrap().is_alive() && process_p2pool.lock().unwrap().is_alive()
{ {
info!("XMRig Process | redirect xmrig to p2pool since XMRig-Proxy is not alive anymore"); info!(
"XMRig Process | redirect xmrig to p2pool since XMRig-Proxy is not alive anymore"
);
let node = XvbNode::P2pool; let node = XvbNode::P2pool;
if let Err(err) = update_xmrig_config( if let Err(err) = update_xmrig_config(
&client, &client,

View file

@ -14,17 +14,17 @@ use tokio::spawn;
use crate::miscs::client; use crate::miscs::client;
use crate::{ use crate::{
GUPAX_VERSION_UNDERSCORE, UNKNOWN_DATA,
disk::state::Xmrig, disk::state::Xmrig,
helper::{ helper::{
check_died, check_user_input, signal_end, sleep_end_loop, Helper, Process, ProcessName, ProcessSignal, ProcessState, check_died, check_user_input,
signal_end, sleep_end_loop,
xrig::update_xmrig_config, xrig::update_xmrig_config,
xvb::{nodes::XvbNode, PubXvbApi}, xvb::{PubXvbApi, nodes::XvbNode},
Helper, Process, ProcessName, ProcessSignal, ProcessState,
}, },
macros::{arc_mut, sleep}, macros::{arc_mut, sleep},
miscs::output_console, miscs::output_console,
regex::{contains_timeout, contains_usepool, detect_new_node_xmrig, XMRIG_REGEX}, regex::{XMRIG_REGEX, contains_timeout, contains_usepool, detect_new_node_xmrig},
GUPAX_VERSION_UNDERSCORE, UNKNOWN_DATA,
}; };
use crate::{NO_POOL, XMRIG_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL}; use crate::{NO_POOL, XMRIG_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL};
@ -412,7 +412,9 @@ impl Helper {
match PrivXmrigProxyApi::request_xp_api(&client, api_summary_xp, token_proxy).await match PrivXmrigProxyApi::request_xp_api(&client, api_summary_xp, token_proxy).await
{ {
Ok(priv_api) => { Ok(priv_api) => {
debug!("XMRig-Proxy Watchdog | HTTP API request OK, attempting [update_from_priv()]"); debug!(
"XMRig-Proxy Watchdog | HTTP API request OK, attempting [update_from_priv()]"
);
PubXmrigProxyApi::update_from_priv(pub_api, priv_api); PubXmrigProxyApi::update_from_priv(pub_api, priv_api);
} }
Err(err) => { Err(err) => {

View file

@ -1,9 +1,9 @@
use crate::XVB_MIN_TIME_SEND;
use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi; use crate::helper::xrig::xmrig_proxy::PubXmrigProxyApi;
use crate::helper::xvb::api_url_xmrig; use crate::helper::xvb::api_url_xmrig;
use crate::helper::xvb::current_controllable_hr; use crate::helper::xvb::current_controllable_hr;
use crate::miscs::output_console; use crate::miscs::output_console;
use crate::miscs::output_console_without_time; use crate::miscs::output_console_without_time;
use crate::XVB_MIN_TIME_SEND;
use std::{ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
time::Duration, time::Duration,
@ -15,17 +15,17 @@ use reqwest_middleware::ClientWithMiddleware as Client;
use tokio::time::sleep; use tokio::time::sleep;
use crate::{ use crate::{
BLOCK_PPLNS_WINDOW_MAIN, BLOCK_PPLNS_WINDOW_MINI, SECOND_PER_BLOCK_P2POOL,
XVB_ROUND_DONOR_MEGA_MIN_HR, XVB_ROUND_DONOR_MIN_HR, XVB_ROUND_DONOR_VIP_MIN_HR,
XVB_ROUND_DONOR_WHALE_MIN_HR, XVB_TIME_ALGO,
helper::{ helper::{
p2pool::PubP2poolApi, p2pool::PubP2poolApi,
xrig::{update_xmrig_config, xmrig::PubXmrigApi}, xrig::{update_xmrig_config, xmrig::PubXmrigApi},
xvb::{nodes::XvbNode, priv_stats::RuntimeMode}, xvb::{nodes::XvbNode, priv_stats::RuntimeMode},
}, },
BLOCK_PPLNS_WINDOW_MAIN, BLOCK_PPLNS_WINDOW_MINI, SECOND_PER_BLOCK_P2POOL,
XVB_ROUND_DONOR_MEGA_MIN_HR, XVB_ROUND_DONOR_MIN_HR, XVB_ROUND_DONOR_VIP_MIN_HR,
XVB_ROUND_DONOR_WHALE_MIN_HR, XVB_TIME_ALGO,
}; };
use super::{priv_stats::RuntimeDonationLevel, PubXvbApi, SamplesAverageHour}; use super::{PubXvbApi, SamplesAverageHour, priv_stats::RuntimeDonationLevel};
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(crate) async fn algorithm( pub(crate) async fn algorithm(
@ -138,7 +138,9 @@ impl<'a> Algorithm<'a> {
); );
let p2pool_external_hashrate = let p2pool_external_hashrate =
(p2pool_total_hashrate - p2pool_avg_last_hour_hashrate).max(0.0); (p2pool_total_hashrate - p2pool_avg_last_hour_hashrate).max(0.0);
info!("p2pool external hashrate({p2pool_external_hashrate}) = p2ool_total_hashrate({p2pool_total_hashrate}) - p2pool_avg_last_hour_hashrate({p2pool_avg_last_hour_hashrate})"); info!(
"p2pool external hashrate({p2pool_external_hashrate}) = p2ool_total_hashrate({p2pool_total_hashrate}) - p2pool_avg_last_hour_hashrate({p2pool_avg_last_hour_hashrate})"
);
let share_min_hashrate = Self::minimum_hashrate_share( let share_min_hashrate = Self::minimum_hashrate_share(
gui_api_p2pool.lock().unwrap().p2pool_difficulty_u64, gui_api_p2pool.lock().unwrap().p2pool_difficulty_u64,
@ -161,7 +163,9 @@ impl<'a> Algorithm<'a> {
&gui_api_xvb.lock().unwrap().xvb_sent_last_hour_samples, &gui_api_xvb.lock().unwrap().xvb_sent_last_hour_samples,
); );
let xvb_external_hashrate = (xvb_1h_avg - xvb_avg_last_hour_hashrate).max(0.0); let xvb_external_hashrate = (xvb_1h_avg - xvb_avg_last_hour_hashrate).max(0.0);
info!("xvb external hashrate({xvb_external_hashrate}) = xvb_1h_avg({xvb_1h_avg}) - xvb_avg_last_hour_hashrate({xvb_avg_last_hour_hashrate})"); info!(
"xvb external hashrate({xvb_external_hashrate}) = xvb_1h_avg({xvb_1h_avg}) - xvb_avg_last_hour_hashrate({xvb_avg_last_hour_hashrate})"
);
let stats = Stats { let stats = Stats {
share, share,
hashrate_xmrig, hashrate_xmrig,
@ -429,10 +433,10 @@ impl<'a> Algorithm<'a> {
let target_donation_hashrate = let target_donation_hashrate =
self.stats.hashrate_xmrig - (self.stats.runtime_amount as f32); self.stats.hashrate_xmrig - (self.stats.runtime_amount as f32);
info!("Algorithm | ManualP2poolMode target_donation_hashrate({})=hashrate_xmrig({})-runtime_amount({})", info!(
target_donation_hashrate, "Algorithm | ManualP2poolMode target_donation_hashrate({})=hashrate_xmrig({})-runtime_amount({})",
self.stats.hashrate_xmrig, target_donation_hashrate, self.stats.hashrate_xmrig, self.stats.runtime_amount
self.stats.runtime_amount); );
target_donation_hashrate target_donation_hashrate
} }
@ -441,9 +445,10 @@ impl<'a> Algorithm<'a> {
let target_donation_hashrate = self.stats.runtime_donation_level.get_hashrate() let target_donation_hashrate = self.stats.runtime_donation_level.get_hashrate()
- self.stats.xvb_external_hashrate; - self.stats.xvb_external_hashrate;
info!("Algorithm | ManualDonationLevelMode target_donation_hashrate({})={:#?}.get_hashrate()", info!(
target_donation_hashrate, "Algorithm | ManualDonationLevelMode target_donation_hashrate({})={:#?}.get_hashrate()",
self.stats.runtime_donation_level); target_donation_hashrate, self.stats.runtime_donation_level
);
target_donation_hashrate target_donation_hashrate
} }
@ -511,13 +516,15 @@ impl<'a> Algorithm<'a> {
* (1.0 + (p2pool_buffer as f32 / 100.0))) * (1.0 + (p2pool_buffer as f32 / 100.0)))
- p2pool_external_hashrate; - p2pool_external_hashrate;
info!("Algorithm | (difficulty({}) / (window pplns blocks({}) * seconds per p2pool block({})) * (BUFFER 1 + ({})) / 100) - outside HR({}H/s) = minimum HR({}H/s) to keep a share.", info!(
"Algorithm | (difficulty({}) / (window pplns blocks({}) * seconds per p2pool block({})) * (BUFFER 1 + ({})) / 100) - outside HR({}H/s) = minimum HR({}H/s) to keep a share.",
difficulty, difficulty,
pws, pws,
SECOND_PER_BLOCK_P2POOL, SECOND_PER_BLOCK_P2POOL,
p2pool_buffer, p2pool_buffer,
p2pool_external_hashrate, p2pool_external_hashrate,
minimum_hr); minimum_hr
);
if minimum_hr.is_sign_negative() { if minimum_hr.is_sign_negative() {
info!("Algorithm | if minimum HR is negative, it is 0."); info!("Algorithm | if minimum HR is negative, it is 0.");
@ -567,16 +574,23 @@ impl<'a> Algorithm<'a> {
match self.stats.needed_time_xvb { match self.stats.needed_time_xvb {
x if x <= XVB_MIN_TIME_SEND => { x if x <= XVB_MIN_TIME_SEND => {
info!("Algorithm | Needed time: {x} to send on XvB is less than minimum time to send, sending all HR to p2pool"); info!(
"Algorithm | Needed time: {x} to send on XvB is less than minimum time to send, sending all HR to p2pool"
);
self.send_all_p2pool().await; self.send_all_p2pool().await;
} }
x if x <= XVB_TIME_ALGO - XVB_MIN_TIME_SEND => { x if x <= XVB_TIME_ALGO - XVB_MIN_TIME_SEND => {
info!("Algorithm | There is a share in p2pool and 24H avg XvB is achieved. Sending {} seconds to XvB!", self.stats.needed_time_xvb); info!(
"Algorithm | There is a share in p2pool and 24H avg XvB is achieved. Sending {} seconds to XvB!",
self.stats.needed_time_xvb
);
self.target_p2pool_node().await; self.target_p2pool_node().await;
self.sleep_then_update_node_xmrig().await; self.sleep_then_update_node_xmrig().await;
} }
x if x >= XVB_TIME_ALGO - XVB_MIN_TIME_SEND => { x if x >= XVB_TIME_ALGO - XVB_MIN_TIME_SEND => {
info!("Algorithm | time : {x} seconds for XvB is more than time algo - minimum time to send, sending all to XvB"); info!(
"Algorithm | time : {x} seconds for XvB is more than time algo - minimum time to send, sending all to XvB"
);
self.send_all_xvb().await; self.send_all_xvb().await;
} }
_ => error!("should not be possible"), _ => error!("should not be possible"),
@ -635,11 +649,10 @@ impl<'a> Algorithm<'a> {
fn get_needed_time_xvb(target_donation_hashrate: f32, hashrate_xmrig: f32) -> u32 { fn get_needed_time_xvb(target_donation_hashrate: f32, hashrate_xmrig: f32) -> u32 {
let needed_time = target_donation_hashrate / hashrate_xmrig * (XVB_TIME_ALGO as f32); let needed_time = target_donation_hashrate / hashrate_xmrig * (XVB_TIME_ALGO as f32);
info!("Algorithm | Calculating... needed time for XvB ({}seconds)=target_donation_hashrate({})/hashrate_xmrig({})*XVB_TIME_ALGO({})", info!(
needed_time, "Algorithm | Calculating... needed time for XvB ({}seconds)=target_donation_hashrate({})/hashrate_xmrig({})*XVB_TIME_ALGO({})",
target_donation_hashrate, needed_time, target_donation_hashrate, hashrate_xmrig, XVB_TIME_ALGO
hashrate_xmrig, );
XVB_TIME_ALGO);
// never go above time of algo // never go above time of algo
// it could be the case if manual donation level is set // it could be the case if manual donation level is set
needed_time.clamp(0.0, XVB_TIME_ALGO as f32) as u32 needed_time.clamp(0.0, XVB_TIME_ALGO as f32) as u32

View file

@ -2,7 +2,7 @@ use crate::helper::xrig::update_xmrig_config;
use crate::helper::xvb::algorithm::algorithm; use crate::helper::xvb::algorithm::algorithm;
use crate::helper::xvb::priv_stats::XvbPrivStats; use crate::helper::xvb::priv_stats::XvbPrivStats;
use crate::helper::xvb::public_stats::XvbPubStats; use crate::helper::xvb::public_stats::XvbPubStats;
use crate::helper::{sleep_end_loop, ProcessName}; use crate::helper::{ProcessName, sleep_end_loop};
use crate::miscs::{client, output_console}; use crate::miscs::{client, output_console};
use crate::{XMRIG_CONFIG_URL, XMRIG_PROXY_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL, XMRIG_SUMMARY_URL}; use crate::{XMRIG_CONFIG_URL, XMRIG_PROXY_CONFIG_URL, XMRIG_PROXY_SUMMARY_URL, XMRIG_SUMMARY_URL};
use bounded_vec_deque::BoundedVecDeque; use bounded_vec_deque::BoundedVecDeque;
@ -18,7 +18,7 @@ use std::{
}; };
use tokio::spawn; use tokio::spawn;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio::time::{sleep, Instant}; use tokio::time::{Instant, sleep};
use crate::helper::xvb::rounds::round_type; use crate::helper::xvb::rounds::round_type;
use crate::utils::constants::{XVB_PUBLIC_ONLY, XVB_TIME_ALGO}; use crate::utils::constants::{XVB_PUBLIC_ONLY, XVB_TIME_ALGO};
@ -488,8 +488,18 @@ async fn check_conditions_for_start(
{ {
info!("XvB | verify address and token"); info!("XvB | verify address and token");
// send to console: token non existent for address on XvB server // send to console: token non existent for address on XvB server
warn!("Xvb | Start ... Partially failed because token and associated address are not existent on XvB server: {}\n", err); warn!(
output_console(&mut gui_api.lock().unwrap().output, &format!("Token and associated address are not valid on XvB API.\nCheck if you are registered.\nError: {}", err), ProcessName::Xvb); "Xvb | Start ... Partially failed because token and associated address are not existent on XvB server: {}\n",
err
);
output_console(
&mut gui_api.lock().unwrap().output,
&format!(
"Token and associated address are not valid on XvB API.\nCheck if you are registered.\nError: {}",
err
),
ProcessName::Xvb,
);
ProcessState::NotMining ProcessState::NotMining
} else if process_p2pool.lock().unwrap().state != ProcessState::Alive { } else if process_p2pool.lock().unwrap().state != ProcessState::Alive {
info!("XvB | verify p2pool node"); info!("XvB | verify p2pool node");
@ -506,7 +516,9 @@ async fn check_conditions_for_start(
&& process_xp.lock().unwrap().state != ProcessState::Alive && process_xp.lock().unwrap().state != ProcessState::Alive
{ {
// send to console: xmrig process is not running // send to console: xmrig process is not running
warn!("Xvb | Start ... Partially failed because Xmrig or Xmrig-Proxy instance is not running."); warn!(
"Xvb | Start ... Partially failed because Xmrig or Xmrig-Proxy instance is not running."
);
// output the error to console // output the error to console
output_console( output_console(
&mut gui_api.lock().unwrap().output, &mut gui_api.lock().unwrap().output,
@ -573,7 +585,7 @@ async fn check_state_outcauses_xvb(
output_console( output_console(
&mut gui_api.lock().unwrap().output, &mut gui_api.lock().unwrap().output,
"XvB process can not completely continue, algorithm of distribution of HR is stopped.", "XvB process can not completely continue, algorithm of distribution of HR is stopped.",
ProcessName::Xvb ProcessName::Xvb,
); );
// only update xmrig if it is alive and wasn't on p2pool already. // only update xmrig if it is alive and wasn't on p2pool already.
if gui_api.lock().unwrap().current_node != Some(XvbNode::P2pool) if gui_api.lock().unwrap().current_node != Some(XvbNode::P2pool)
@ -638,7 +650,9 @@ async fn check_state_outcauses_xvb(
match state { match state {
ProcessState::Alive if !p2pool_xmrig_alive => { ProcessState::Alive if !p2pool_xmrig_alive => {
// they are not both alives, so state will be at syncing and data reset, state of loop also. // they are not both alives, so state will be at syncing and data reset, state of loop also.
warn!("XvB | stopped partially because P2pool node or xmrig/xmrig-proxy are not reachable."); warn!(
"XvB | stopped partially because P2pool node or xmrig/xmrig-proxy are not reachable."
);
// stats must be empty put to default so the UI reflect that XvB private is not running. // stats must be empty put to default so the UI reflect that XvB private is not running.
reset_data_xvb(pub_api, gui_api); reset_data_xvb(pub_api, gui_api);
// request from public API must be executed at next loop, do not wait for 1 minute. // request from public API must be executed at next loop, do not wait for 1 minute.
@ -646,7 +660,7 @@ async fn check_state_outcauses_xvb(
output_console( output_console(
&mut gui_api.lock().unwrap().output, &mut gui_api.lock().unwrap().output,
"XvB is now partially stopped because p2pool node or XMRig/XMRig-Proxy came offline.\nCheck P2pool and Xmrig/Xmrig-Proxy Tabs", "XvB is now partially stopped because p2pool node or XMRig/XMRig-Proxy came offline.\nCheck P2pool and Xmrig/Xmrig-Proxy Tabs",
ProcessName::Xvb ProcessName::Xvb,
); );
output_console( output_console(
&mut gui_api.lock().unwrap().output, &mut gui_api.lock().unwrap().output,

View file

@ -9,9 +9,9 @@ use reqwest_middleware::ClientWithMiddleware as Client;
use tokio::spawn; use tokio::spawn;
use crate::{ use crate::{
components::node::{GetInfo, TIMEOUT_NODE_PING},
helper::{xvb::output_console, Process, ProcessName, ProcessState},
GUPAX_VERSION_UNDERSCORE, XVB_NODE_EU, XVB_NODE_NA, XVB_NODE_PORT, XVB_NODE_RPC, GUPAX_VERSION_UNDERSCORE, XVB_NODE_EU, XVB_NODE_NA, XVB_NODE_PORT, XVB_NODE_RPC,
components::node::{GetInfo, TIMEOUT_NODE_PING},
helper::{Process, ProcessName, ProcessState, xvb::output_console},
}; };
use super::PubXvbApi; use super::PubXvbApi;

View file

@ -10,16 +10,16 @@ use reqwest_middleware::ClientWithMiddleware as Client;
use serde::Deserialize; use serde::Deserialize;
use crate::{ use crate::{
disk::state::ManualDonationLevel, XVB_ROUND_DONOR_MEGA_MIN_HR, XVB_ROUND_DONOR_MIN_HR, XVB_ROUND_DONOR_VIP_MIN_HR,
helper::{xvb::output_console, Process, ProcessName, ProcessState}, XVB_ROUND_DONOR_WHALE_MIN_HR, disk::state::XvbMode,
XVB_URL,
}; };
use crate::{ use crate::{
disk::state::XvbMode, XVB_ROUND_DONOR_MEGA_MIN_HR, XVB_ROUND_DONOR_MIN_HR, XVB_URL,
XVB_ROUND_DONOR_VIP_MIN_HR, XVB_ROUND_DONOR_WHALE_MIN_HR, disk::state::ManualDonationLevel,
helper::{Process, ProcessName, ProcessState, xvb::output_console},
}; };
use super::{nodes::XvbNode, rounds::XvbRound, PubXvbApi}; use super::{PubXvbApi, nodes::XvbNode, rounds::XvbRound};
#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Default)] #[derive(Debug, Clone, Deserialize, PartialEq, Eq, Default)]
pub enum RuntimeMode { pub enum RuntimeMode {
@ -97,7 +97,10 @@ impl XvbPrivStats {
StatusCode::OK => match resp.json::<Self>().await { StatusCode::OK => match resp.json::<Self>().await {
Ok(s) => Ok(s), Ok(s) => Ok(s),
Err(err) => { Err(err) => {
error!("XvB Watchdog | Data provided from private API is not deserializ-able.Error: {}", err); error!(
"XvB Watchdog | Data provided from private API is not deserializ-able.Error: {}",
err
);
bail!( bail!(
"Data provided from private API is not deserializ-able.Error: {}", "Data provided from private API is not deserializ-able.Error: {}",
err err

View file

@ -9,11 +9,11 @@ use serde::Deserialize;
use serde_this_or_that::as_u64; use serde_this_or_that::as_u64;
use crate::{ use crate::{
helper::{xvb::output_console, Process, ProcessName, ProcessState},
XVB_URL_PUBLIC_API, XVB_URL_PUBLIC_API,
helper::{Process, ProcessName, ProcessState, xvb::output_console},
}; };
use super::{rounds::XvbRound, PubXvbApi}; use super::{PubXvbApi, rounds::XvbRound};
#[allow(dead_code)] // because deserialize doesn't use all the fields #[allow(dead_code)] // because deserialize doesn't use all the fields
#[derive(Debug, Clone, Default, Deserialize)] #[derive(Debug, Clone, Default, Deserialize)]

View file

@ -1,4 +1,4 @@
use crate::components::update::{check_binary_path, Update}; use crate::components::update::{Update, check_binary_path};
use crate::errors::process_running; use crate::errors::process_running;
use crate::helper::{Helper, ProcessName, ProcessSignal}; use crate::helper::{Helper, ProcessName, ProcessSignal};
use crate::utils::constants::{ use crate::utils::constants::{
@ -66,7 +66,6 @@ pub fn init_logger(now: Instant, logfile: bool) {
"trace" | "Trace" | "TRACE" => LevelFilter::Trace, "trace" | "Trace" | "TRACE" => LevelFilter::Trace,
_ => LevelFilter::Info, _ => LevelFilter::Info,
}; };
std::env::set_var("RUST_LOG", format!("off,gupax={}", filter_env));
Builder::new() Builder::new()
.format(move |buf, record| { .format(move |buf, record| {
@ -162,7 +161,9 @@ pub fn init_auto(app: &mut App) {
} else if !check_binary_path(&app.state.gupax.node_path, ProcessName::Node) { } else if !check_binary_path(&app.state.gupax.node_path, ProcessName::Node) {
warn!("Gupaxx | Node path is not valid! Skipping auto-node..."); warn!("Gupaxx | Node path is not valid! Skipping auto-node...");
} else if process_running(ProcessName::Node) { } else if process_running(ProcessName::Node) {
warn!("Gupaxx | Node instance is already running outside of Gupaxx ! Skipping auto-node..."); warn!(
"Gupaxx | Node instance is already running outside of Gupaxx ! Skipping auto-node..."
);
} else { } else {
// enable hugepage on linux // enable hugepage on linux
// sudo sysctl vm.nr_hugepages=3072 // sudo sysctl vm.nr_hugepages=3072
@ -184,7 +185,9 @@ pub fn init_auto(app: &mut App) {
} else if !check_binary_path(&app.state.gupax.p2pool_path, ProcessName::P2pool) { } else if !check_binary_path(&app.state.gupax.p2pool_path, ProcessName::P2pool) {
warn!("Gupaxx | P2Pool path is not valid! Skipping auto-p2pool..."); warn!("Gupaxx | P2Pool path is not valid! Skipping auto-p2pool...");
} else if process_running(crate::helper::ProcessName::P2pool) { } else if process_running(crate::helper::ProcessName::P2pool) {
warn!("Gupaxx | P2pool instance is already running outside of Gupaxx ! Skipping auto-node..."); warn!(
"Gupaxx | P2pool instance is already running outside of Gupaxx ! Skipping auto-node..."
);
} else { } else {
let backup_hosts = app.gather_backup_hosts(); let backup_hosts = app.gather_backup_hosts();
Helper::start_p2pool( Helper::start_p2pool(
@ -205,7 +208,9 @@ pub fn init_auto(app: &mut App) {
} else if !check_binary_path(&app.state.gupax.xmrig_path, ProcessName::Xmrig) { } else if !check_binary_path(&app.state.gupax.xmrig_path, ProcessName::Xmrig) {
warn!("Gupaxx | XMRig path is not valid! Skipping auto-xmrig..."); warn!("Gupaxx | XMRig path is not valid! Skipping auto-xmrig...");
} else if process_running(crate::helper::ProcessName::Xmrig) { } else if process_running(crate::helper::ProcessName::Xmrig) {
warn!("Gupaxx | Xmrig instance is already running outside of Gupaxx ! Skipping auto-node..."); warn!(
"Gupaxx | Xmrig instance is already running outside of Gupaxx ! Skipping auto-node..."
);
} else if cfg!(windows) { } else if cfg!(windows) {
Helper::start_xmrig( Helper::start_xmrig(
&app.helper, &app.helper,
@ -227,7 +232,9 @@ pub fn init_auto(app: &mut App) {
} else if !check_binary_path(&app.state.gupax.xmrig_proxy_path, ProcessName::XmrigProxy) { } else if !check_binary_path(&app.state.gupax.xmrig_proxy_path, ProcessName::XmrigProxy) {
warn!("Gupaxx | Xmrig-Proxy path is not valid! Skipping auto-xmrig_proxy..."); warn!("Gupaxx | Xmrig-Proxy path is not valid! Skipping auto-xmrig_proxy...");
} else if process_running(crate::helper::ProcessName::XmrigProxy) { } else if process_running(crate::helper::ProcessName::XmrigProxy) {
warn!("Gupaxx | Xmrig-Proxy instance is already running outside of Gupaxx ! Skipping auto-node..."); warn!(
"Gupaxx | Xmrig-Proxy instance is already running outside of Gupaxx ! Skipping auto-node..."
);
} else { } else {
Helper::start_xp( Helper::start_xp(
&app.helper, &app.helper,

View file

@ -29,9 +29,7 @@ use crate::app::App;
use crate::cli::Cli; use crate::cli::Cli;
//---------------------------------------------------------------------------------------------------- Imports //---------------------------------------------------------------------------------------------------- Imports
use crate::constants::*; use crate::constants::*;
use crate::inits::init_auto; use crate::inits::{init_auto, init_logger, init_options};
use crate::inits::init_logger;
use crate::inits::init_options;
use crate::miscs::clean_dir; use crate::miscs::clean_dir;
use crate::utils::*; use crate::utils::*;
use clap::Parser; use clap::Parser;
@ -71,7 +69,9 @@ fn main() {
let selected_height = app.state.gupax.selected_height as f32; let selected_height = app.state.gupax.selected_height as f32;
let initial_window_size = if selected_width > APP_MAX_WIDTH || selected_height > APP_MAX_HEIGHT let initial_window_size = if selected_width > APP_MAX_WIDTH || selected_height > APP_MAX_HEIGHT
{ {
warn!("App | Set width or height was greater than the maximum! Starting with the default resolution..."); warn!(
"App | Set width or height was greater than the maximum! Starting with the default resolution..."
);
Some(Vec2::new(APP_DEFAULT_WIDTH, APP_DEFAULT_HEIGHT)) Some(Vec2::new(APP_DEFAULT_WIDTH, APP_DEFAULT_HEIGHT))
} else { } else {
Some(Vec2::new( Some(Vec2::new(
@ -90,7 +90,9 @@ fn main() {
let resolution = Vec2::new(selected_width, selected_height); let resolution = Vec2::new(selected_width, selected_height);
// Run Gupax. // Run Gupax.
info!("/*************************************/ Init ... OK /*************************************/"); info!(
"/*************************************/ Init ... OK /*************************************/"
);
eframe::run_native( eframe::run_native(
&app.name_version.clone(), &app.name_version.clone(),
options, options,

View file

@ -204,8 +204,7 @@ pub const OS_NAME: &str = "Linux";
// Tooltips // Tooltips
// Status // Status
pub const STATUS_GUPAX_UPTIME: &str = "How long Gupaxx has been online"; pub const STATUS_GUPAX_UPTIME: &str = "How long Gupaxx has been online";
pub const STATUS_GUPAX_CPU_USAGE: &str = pub const STATUS_GUPAX_CPU_USAGE: &str = "How much CPU Gupaxx is currently using. This accounts for all your threads (it is out of 100%)";
"How much CPU Gupaxx is currently using. This accounts for all your threads (it is out of 100%)";
pub const STATUS_GUPAX_MEMORY_USAGE: &str = pub const STATUS_GUPAX_MEMORY_USAGE: &str =
"How much memory Gupaxx is currently using in Megabytes"; "How much memory Gupaxx is currently using in Megabytes";
pub const STATUS_GUPAX_SYSTEM_CPU_USAGE: &str = "How much CPU your entire system is currently using. This accounts for all your threads (it is out of 100%)"; pub const STATUS_GUPAX_SYSTEM_CPU_USAGE: &str = "How much CPU your entire system is currently using. This accounts for all your threads (it is out of 100%)";
@ -316,11 +315,9 @@ pub const STATUS_SUBMENU_OTHER_BENCHMARKS: &str =
"How many benchmarks this CPU has had posted to [https://xmrig.com/benchmark]"; "How many benchmarks this CPU has had posted to [https://xmrig.com/benchmark]";
// Gupaxx // Gupaxx
pub const GUPAX_UPDATE: &str = pub const GUPAX_UPDATE: &str = "Check for updates on Gupaxx and bundled versions of P2Pool and XMRig via GitHub's API and upgrade automatically";
"Check for updates on Gupaxx and bundled versions of P2Pool and XMRig via GitHub's API and upgrade automatically";
pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup"; pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup";
pub const GUPAX_BUNDLED_UPDATE: &str = pub const GUPAX_BUNDLED_UPDATE: &str = "Update XMRig and P2Pool with bundled versions of latest Gupaxx. It will replace any present xmrig and p2pool binary in their specified path.";
"Update XMRig and P2Pool with bundled versions of latest Gupaxx. It will replace any present xmrig and p2pool binary in their specified path.";
pub const GUPAX_SHOULD_RESTART: &str = pub const GUPAX_SHOULD_RESTART: &str =
"Gupaxx was updated. A restart is recommended but not required"; "Gupaxx was updated. A restart is recommended but not required";
// #[cfg(not(target_os = "macos"))] // #[cfg(not(target_os = "macos"))]
@ -528,8 +525,7 @@ pub const XVB_SIDE_MARGIN_1H: f32 = 1.20;
pub const XVB_TIME_ALGO: u32 = 600; pub const XVB_TIME_ALGO: u32 = 600;
pub const XVB_MIN_TIME_SEND: u32 = (XVB_TIME_ALGO as f32 * 0.01) as u32; pub const XVB_MIN_TIME_SEND: u32 = (XVB_TIME_ALGO as f32 * 0.01) as u32;
pub const XVB_TOKEN_LEN: usize = 9; pub const XVB_TOKEN_LEN: usize = 9;
pub const XVB_HERO_SELECT: &str = pub const XVB_HERO_SELECT: &str = "Donate as much as possible while keeping a share on p2pool, increases the odds of your round winning\nWhen modified, the algorithm will use the new choice at the next decision.";
"Donate as much as possible while keeping a share on p2pool, increases the odds of your round winning\nWhen modified, the algorithm will use the new choice at the next decision.";
pub const XVB_TOKEN_FIELD: &str = "Token"; pub const XVB_TOKEN_FIELD: &str = "Token";
pub const XVB_FAILURE_FIELD: &str = "Failures"; pub const XVB_FAILURE_FIELD: &str = "Failures";
pub const XVB_DONATED_1H_FIELD: &str = "Donated last hour"; pub const XVB_DONATED_1H_FIELD: &str = "Donated last hour";

View file

@ -184,7 +184,9 @@ pub fn detect_new_node_xmrig(s: &str) -> Option<XvbNode> {
} }
} }
} }
warn!("a line on xmrig console was detected as using a new pool but the syntax was not recognized or it was not a pool useable for the algorithm."); warn!(
"a line on xmrig console was detected as using a new pool but the syntax was not recognized or it was not a pool useable for the algorithm."
);
None None
} }
// this detection removes the need to update pub_api.node everytime xmrig/proxy are updated to mine to another p2pool node. // this detection removes the need to update pub_api.node everytime xmrig/proxy are updated to mine to another p2pool node.
@ -204,7 +206,9 @@ pub fn detect_node_xmrig(s: &str) -> Option<String> {
return Some(name); return Some(name);
} }
} }
warn!("a line on xmrig console was detected as using a new pool but the syntax was not recognized or it was not a pool useable for the algorithm."); warn!(
"a line on xmrig console was detected as using a new pool but the syntax was not recognized or it was not a pool useable for the algorithm."
);
None None
} }
pub fn estimated_hr(s: &str) -> Option<f32> { pub fn estimated_hr(s: &str) -> Option<f32> {
@ -282,7 +286,10 @@ mod test {
fn build_regexes() { fn build_regexes() {
let r = Regexes::new(); let r = Regexes::new();
assert!(Regex::is_match(&r.name, "_this_ is... a n-a-m-e.")); assert!(Regex::is_match(&r.name, "_this_ is... a n-a-m-e."));
assert!(Regex::is_match(&r.address, "44hintoFpuo3ugKfcqJvh5BmrsTRpnTasJmetKC4VXCt6QDtbHVuixdTtsm6Ptp7Y8haXnJ6j8Gj2dra8CKy5ewz7Vi9CYW")); assert!(Regex::is_match(
&r.address,
"44hintoFpuo3ugKfcqJvh5BmrsTRpnTasJmetKC4VXCt6QDtbHVuixdTtsm6Ptp7Y8haXnJ6j8Gj2dra8CKy5ewz7Vi9CYW"
));
assert!(Regex::is_match(&r.ipv4, "192.168.1.2")); assert!(Regex::is_match(&r.ipv4, "192.168.1.2"));
assert!(Regex::is_match(&r.ipv4, "127.0.0.1")); assert!(Regex::is_match(&r.ipv4, "127.0.0.1"));
assert!(Regex::is_match(&r.domain, "sub.domain.com")); assert!(Regex::is_match(&r.domain, "sub.domain.com"));