mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 15:27:46 +00:00
fix: all clippy warnings
This commit is contained in:
parent
0f67fe7a08
commit
135de3d556
20 changed files with 105 additions and 214 deletions
|
@ -47,7 +47,7 @@
|
|||
- [ ] adapt doc for new code
|
||||
- [ ] cargo package metadata
|
||||
- [ ] pgp signatures
|
||||
- [ ] fix clippy
|
||||
- [x] fix clippy
|
||||
- [ ] optimizations
|
||||
- [ ] better organize new code
|
||||
- [ ] merge commits from upstream
|
||||
|
|
|
@ -326,11 +326,11 @@ impl App {
|
|||
|
||||
info!("App Init | Setting TOML path...");
|
||||
// Set [*.toml] path
|
||||
app.state_path = app.os_data_path.clone();
|
||||
app.state_path.clone_from(&app.os_data_path);
|
||||
app.state_path.push(STATE_TOML);
|
||||
app.node_path = app.os_data_path.clone();
|
||||
app.node_path.clone_from(&app.os_data_path);
|
||||
app.node_path.push(NODE_TOML);
|
||||
app.pool_path = app.os_data_path.clone();
|
||||
app.pool_path.clone_from(&app.os_data_path);
|
||||
app.pool_path.push(POOL_TOML);
|
||||
// Set GupaxP2poolApi path
|
||||
app.gupax_p2pool_api_path = crate::disk::get_gupax_p2pool_path(&app.os_data_path);
|
||||
|
@ -388,7 +388,7 @@ impl App {
|
|||
Node::new_vec()
|
||||
}
|
||||
};
|
||||
app.og_node_vec = app.node_vec.clone();
|
||||
app.og_node_vec.clone_from(&app.node_vec);
|
||||
debug!("Node Vec:");
|
||||
debug!("{:#?}", app.node_vec);
|
||||
// Read pool list
|
||||
|
@ -410,7 +410,7 @@ impl App {
|
|||
Pool::new_vec()
|
||||
}
|
||||
};
|
||||
app.og_pool_vec = app.pool_vec.clone();
|
||||
app.og_pool_vec.clone_from(&app.pool_vec);
|
||||
debug!("Pool Vec:");
|
||||
debug!("{:#?}", app.pool_vec);
|
||||
|
||||
|
@ -481,10 +481,10 @@ impl App {
|
|||
None => Node::new_tuple(),
|
||||
};
|
||||
og.p2pool.selected_index = 0;
|
||||
og.p2pool.selected_name = name.clone();
|
||||
og.p2pool.selected_ip = node.ip.clone();
|
||||
og.p2pool.selected_rpc = node.rpc.clone();
|
||||
og.p2pool.selected_zmq = node.zmq.clone();
|
||||
og.p2pool.selected_name.clone_from(&name);
|
||||
og.p2pool.selected_ip.clone_from(&node.ip);
|
||||
og.p2pool.selected_rpc.clone_from(&node.rpc);
|
||||
og.p2pool.selected_zmq.clone_from(&node.zmq);
|
||||
app.state.p2pool.selected_index = 0;
|
||||
app.state.p2pool.selected_name = name;
|
||||
app.state.p2pool.selected_ip = node.ip;
|
||||
|
@ -504,9 +504,9 @@ impl App {
|
|||
None => Pool::new_tuple(),
|
||||
};
|
||||
og.xmrig.selected_index = 0;
|
||||
og.xmrig.selected_name = name.clone();
|
||||
og.xmrig.selected_ip = pool.ip.clone();
|
||||
og.xmrig.selected_port = pool.port.clone();
|
||||
og.xmrig.selected_name.clone_from(&name);
|
||||
og.xmrig.selected_ip.clone_from(&pool.ip);
|
||||
og.xmrig.selected_port.clone_from(&pool.port);
|
||||
app.state.xmrig.selected_index = 0;
|
||||
app.state.xmrig.selected_name = name;
|
||||
app.state.xmrig.selected_ip = pool.ip;
|
||||
|
|
|
@ -143,8 +143,8 @@ impl crate::app::App {
|
|||
self.state.p2pool = og.p2pool;
|
||||
self.state.xmrig = og.xmrig;
|
||||
self.state.xvb = og.xvb;
|
||||
self.node_vec = self.og_node_vec.clone();
|
||||
self.pool_vec = self.og_pool_vec.clone();
|
||||
self.node_vec.clone_from(&self.og_node_vec);
|
||||
self.pool_vec.clone_from(&self.og_pool_vec);
|
||||
}
|
||||
if key.is_s() && !wants_input && self.diff
|
||||
|| ui
|
||||
|
@ -170,7 +170,7 @@ impl crate::app::App {
|
|||
}
|
||||
};
|
||||
match Node::save(&self.node_vec, &self.node_path) {
|
||||
Ok(_) => self.og_node_vec = self.node_vec.clone(),
|
||||
Ok(_) => self.og_node_vec.clone_from(&self.node_vec),
|
||||
Err(e) => self.error_state.set(
|
||||
format!("Node list: {}", e),
|
||||
ErrorFerris::Error,
|
||||
|
@ -178,7 +178,7 @@ impl crate::app::App {
|
|||
),
|
||||
};
|
||||
match Pool::save(&self.pool_vec, &self.pool_path) {
|
||||
Ok(_) => self.og_pool_vec = self.pool_vec.clone(),
|
||||
Ok(_) => self.og_pool_vec.clone_from(&self.pool_vec),
|
||||
Err(e) => self.error_state.set(
|
||||
format!("Pool list: {}", e),
|
||||
ErrorFerris::Error,
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use crate::app::panels::middle::*;
|
||||
use crate::app::ErrorState;
|
||||
use crate::app::Restart;
|
||||
use crate::components::gupax::FileWindow;
|
||||
use crate::components::gupax::*;
|
||||
use crate::components::update::Update;
|
||||
use crate::disk::state::*;
|
||||
use crate::macros::lock2;
|
||||
use egui::Button;
|
||||
use log::debug;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
@ -216,11 +214,11 @@ impl Gupax {
|
|||
});
|
||||
let mut guard = lock!(file_window);
|
||||
if guard.picked_p2pool {
|
||||
self.p2pool_path = guard.p2pool_path.clone();
|
||||
self.p2pool_path.clone_from(&guard.p2pool_path);
|
||||
guard.picked_p2pool = false;
|
||||
}
|
||||
if guard.picked_xmrig {
|
||||
self.xmrig_path = guard.xmrig_path.clone();
|
||||
self.xmrig_path.clone_from(&guard.xmrig_path);
|
||||
guard.picked_xmrig = false;
|
||||
}
|
||||
drop(guard);
|
||||
|
|
|
@ -123,11 +123,11 @@ impl P2pool {
|
|||
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
||||
self.selected_index = n;
|
||||
let node = node.clone();
|
||||
self.selected_name = name.clone();
|
||||
self.selected_ip = node.ip.clone();
|
||||
self.selected_rpc = node.rpc.clone();
|
||||
self.selected_zmq = node.zmq.clone();
|
||||
self.name = name.clone();
|
||||
self.selected_name.clone_from(name);
|
||||
self.selected_ip.clone_from(&node.ip);
|
||||
self.selected_rpc.clone_from(&node.rpc);
|
||||
self.selected_zmq.clone_from(&node.zmq);
|
||||
self.name.clone_from(name);
|
||||
self.ip = node.ip;
|
||||
self.rpc = node.rpc;
|
||||
self.zmq = node.zmq;
|
||||
|
@ -163,9 +163,9 @@ impl P2pool {
|
|||
};
|
||||
node_vec[existing_index].1 = node;
|
||||
self.selected_index = existing_index;
|
||||
self.selected_ip = self.ip.clone();
|
||||
self.selected_rpc = self.rpc.clone();
|
||||
self.selected_zmq = self.zmq.clone();
|
||||
self.selected_ip.clone_from(&self.ip);
|
||||
self.selected_rpc.clone_from(&self.rpc);
|
||||
self.selected_zmq.clone_from(&self.zmq);
|
||||
info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", existing_index+1, self.name, self.ip, self.rpc, self.zmq);
|
||||
}
|
||||
// Else, add to the list
|
||||
|
@ -179,10 +179,10 @@ impl P2pool {
|
|||
};
|
||||
node_vec.push((self.name.clone(), node));
|
||||
self.selected_index = node_vec_len;
|
||||
self.selected_name = self.name.clone();
|
||||
self.selected_ip = self.ip.clone();
|
||||
self.selected_rpc = self.rpc.clone();
|
||||
self.selected_zmq = self.zmq.clone();
|
||||
self.selected_name.clone_from(&self.name);
|
||||
self.selected_ip.clone_from(&self.ip);
|
||||
self.selected_rpc.clone_from(&self.rpc);
|
||||
self.selected_zmq.clone_from(&self.zmq);
|
||||
info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", rpc: {}, zmq: {}]", node_vec_len, self.name, self.ip, self.rpc, self.zmq);
|
||||
}
|
||||
}
|
||||
|
@ -207,10 +207,10 @@ impl P2pool {
|
|||
new_node = node_vec[self.selected_index].1.clone();
|
||||
}
|
||||
};
|
||||
self.selected_name = new_name.clone();
|
||||
self.selected_ip = new_node.ip.clone();
|
||||
self.selected_rpc = new_node.rpc.clone();
|
||||
self.selected_zmq = new_node.zmq.clone();
|
||||
self.selected_name.clone_from(&new_name);
|
||||
self.selected_ip.clone_from(&new_node.ip);
|
||||
self.selected_rpc.clone_from(&new_node.rpc);
|
||||
self.selected_zmq.clone_from(&new_node.zmq);
|
||||
self.name = new_name;
|
||||
self.ip = new_node.ip;
|
||||
self.rpc = new_node.rpc;
|
||||
|
|
|
@ -295,11 +295,11 @@ impl Xmrig {
|
|||
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
||||
self.selected_index = n;
|
||||
let pool = pool.clone();
|
||||
self.selected_name = name.clone();
|
||||
self.selected_rig = pool.rig.clone();
|
||||
self.selected_ip = pool.ip.clone();
|
||||
self.selected_port = pool.port.clone();
|
||||
self.name = name.clone();
|
||||
self.selected_name.clone_from(name);
|
||||
self.selected_rig.clone_from(&pool.rig);
|
||||
self.selected_ip.clone_from(&pool.ip);
|
||||
self.selected_port.clone_from(&pool.port);
|
||||
self.name.clone_from(name);
|
||||
self.rig = pool.rig;
|
||||
self.ip = pool.ip;
|
||||
self.port = pool.port;
|
||||
|
@ -334,10 +334,10 @@ impl Xmrig {
|
|||
port: self.port.clone(),
|
||||
};
|
||||
pool_vec[existing_index].1 = pool;
|
||||
self.selected_name = self.name.clone();
|
||||
self.selected_rig = self.rig.clone();
|
||||
self.selected_ip = self.ip.clone();
|
||||
self.selected_port = self.port.clone();
|
||||
self.selected_name.clone_from(&self.name);
|
||||
self.selected_rig.clone_from(&self.rig);
|
||||
self.selected_ip.clone_from(&self.ip);
|
||||
self.selected_port.clone_from(&self.port);
|
||||
info!("Node | S | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", existing_index+1, self.name, self.ip, self.port, self.rig);
|
||||
}
|
||||
// Else, add to the list
|
||||
|
@ -351,10 +351,10 @@ impl Xmrig {
|
|||
};
|
||||
pool_vec.push((self.name.clone(), pool));
|
||||
self.selected_index = pool_vec_len;
|
||||
self.selected_name = self.name.clone();
|
||||
self.selected_rig = self.rig.clone();
|
||||
self.selected_ip = self.ip.clone();
|
||||
self.selected_port = self.port.clone();
|
||||
self.selected_name.clone_from(&self.name);
|
||||
self.selected_rig.clone_from(&self.rig);
|
||||
self.selected_ip.clone_from(&self.ip);
|
||||
self.selected_port.clone_from(&self.port);
|
||||
info!("Node | A | [index: {}, name: \"{}\", ip: \"{}\", port: {}, rig: \"{}\"]", pool_vec_len, self.name, self.ip, self.port, self.rig);
|
||||
}
|
||||
}
|
||||
|
@ -379,10 +379,10 @@ impl Xmrig {
|
|||
new_pool = pool_vec[self.selected_index].1.clone();
|
||||
}
|
||||
};
|
||||
self.selected_name = new_name.clone();
|
||||
self.selected_rig = new_pool.rig.clone();
|
||||
self.selected_ip = new_pool.ip.clone();
|
||||
self.selected_port = new_pool.port.clone();
|
||||
self.selected_name.clone_from(&new_name);
|
||||
self.selected_rig.clone_from(&new_pool.rig);
|
||||
self.selected_ip.clone_from(&new_pool.ip);
|
||||
self.selected_port.clone_from(&new_pool.port);
|
||||
self.name = new_name;
|
||||
self.rig = new_pool.rig;
|
||||
self.ip = new_pool.ip;
|
||||
|
|
|
@ -246,7 +246,7 @@ impl crate::app::App {
|
|||
Ok(_) => match Node::get(&self.node_path) {
|
||||
Ok(s) => {
|
||||
self.node_vec = s;
|
||||
self.og_node_vec = self.node_vec.clone();
|
||||
self.og_node_vec.clone_from(&self.node_vec);
|
||||
self.error_state.set(
|
||||
"Node read OK",
|
||||
ErrorFerris::Happy,
|
||||
|
|
|
@ -54,7 +54,7 @@ pub const REMOTE_NODES: [(&str, &str, &str, &str); 19] = [
|
|||
pub const REMOTE_NODE_LENGTH: usize = REMOTE_NODES.len();
|
||||
|
||||
// Iterate through all nodes, find the longest domain.
|
||||
pub const REMOTE_NODE_MAX_CHARS: usize = {
|
||||
const REMOTE_NODE_MAX_CHARS: usize = {
|
||||
let mut len = 0;
|
||||
let mut index = 0;
|
||||
|
||||
|
@ -103,21 +103,6 @@ impl RemoteNode {
|
|||
ip
|
||||
}
|
||||
|
||||
// Returns a default if IP is not found.
|
||||
pub fn from_ip(from_ip: &str) -> Self {
|
||||
for (ip, location, rpc, zmq) in REMOTE_NODES {
|
||||
if from_ip == ip {
|
||||
return Self {
|
||||
ip,
|
||||
location,
|
||||
rpc,
|
||||
zmq,
|
||||
};
|
||||
}
|
||||
}
|
||||
Self::new()
|
||||
}
|
||||
|
||||
// Returns a default if index is not found in the const array.
|
||||
pub fn from_index(index: usize) -> Self {
|
||||
if index > REMOTE_NODE_LENGTH {
|
||||
|
@ -133,16 +118,6 @@ impl RemoteNode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_tuple(t: (&'static str, &'static str, &'static str, &'static str)) -> Self {
|
||||
let (ip, location, rpc, zmq) = (t.0, t.1, t.2, t.3);
|
||||
Self {
|
||||
ip,
|
||||
location,
|
||||
rpc,
|
||||
zmq,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_ip_rpc_zmq(og_ip: &str) -> (&str, &str, &str) {
|
||||
for (ip, _, rpc, zmq) in REMOTE_NODES {
|
||||
if og_ip == ip {
|
||||
|
@ -266,7 +241,7 @@ pub fn format_ip_location(og_ip: &str, extra_space: bool) -> String {
|
|||
}
|
||||
|
||||
pub fn format_ip(ip: &str) -> String {
|
||||
const _: () = if 23 != REMOTE_NODE_MAX_CHARS {
|
||||
if 23 != REMOTE_NODE_MAX_CHARS {
|
||||
panic!();
|
||||
};
|
||||
format!("{ip: >23}")
|
||||
|
|
|
@ -94,9 +94,9 @@ const GUPAX_SUFFIX: &str = "/gupax-";
|
|||
const P2POOL_SUFFIX: &str = "/p2pool-";
|
||||
const XMRIG_SUFFIX: &str = "/xmrig-";
|
||||
|
||||
const GUPAX_HASH: &str = "SHA256SUMS";
|
||||
const P2POOL_HASH: &str = "sha256sums.txt.asc";
|
||||
const XMRIG_HASH: &str = "SHA256SUMS";
|
||||
// const GUPAX_HASH: &str = "SHA256SUMS";
|
||||
// const P2POOL_HASH: &str = "sha256sums.txt.asc";
|
||||
// const XMRIG_HASH: &str = "SHA256SUMS";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
mod impl_platform {
|
||||
|
@ -122,8 +122,8 @@ mod impl_platform {
|
|||
#[cfg(target_family = "unix")]
|
||||
mod impl_unix {
|
||||
pub(super) const GUPAX_BINARY: &str = "gupax";
|
||||
pub(super) const P2POOL_BINARY: &str = "p2pool";
|
||||
pub(super) const XMRIG_BINARY: &str = "xmrig";
|
||||
// pub(super) const P2POOL_BINARY: &str = "p2pool";
|
||||
// pub(super) const XMRIG_BINARY: &str = "xmrig";
|
||||
pub(super) const VALID_GUPAX_1: &str = "GUPAX";
|
||||
pub(super) const VALID_GUPAX_2: &str = "Gupax";
|
||||
pub(super) const VALID_GUPAX_3: &str = "gupax";
|
||||
|
@ -168,7 +168,7 @@ mod impl_platform {
|
|||
|
||||
use impl_platform::*;
|
||||
|
||||
const VALID_GUPAX: [&str; 3] = [VALID_GUPAX_1, VALID_GUPAX_2, VALID_GUPAX_3];
|
||||
// const VALID_GUPAX: [&str; 3] = [VALID_GUPAX_1, VALID_GUPAX_2, VALID_GUPAX_3];
|
||||
const VALID_XMRIG: [&str; 4] = [VALID_XMRIG_1, VALID_XMRIG_2, VALID_XMRIG_3, VALID_XMRIG_4];
|
||||
const VALID_P2POOL: [&str; 4] = [
|
||||
VALID_P2POOL_1,
|
||||
|
|
|
@ -109,29 +109,6 @@ pub fn set_unix_750_perms(path: &PathBuf) -> Result<(), TomlError> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_unix_660_perms(path: &PathBuf) -> Result<(), TomlError> {
|
||||
#[cfg(target_os = "windows")]
|
||||
return Ok(());
|
||||
#[cfg(target_family = "unix")]
|
||||
match fs::set_permissions(path, fs::Permissions::from_mode(0o660)) {
|
||||
Ok(_) => {
|
||||
info!(
|
||||
"OS | Unix 660 permissions on path [{}] ... OK",
|
||||
path.display()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!(
|
||||
"OS | Unix 660 permissions on path [{}] ... FAIL ... {}",
|
||||
path.display(),
|
||||
e
|
||||
);
|
||||
Err(TomlError::Io(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_gupax_p2pool_path(os_data_path: &Path) -> PathBuf {
|
||||
let mut gupax_p2pool_dir = os_data_path.to_path_buf();
|
||||
gupax_p2pool_dir.push(GUPAX_P2POOL_API_DIRECTORY);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::disk::TomlError;
|
||||
use crate::disk::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
//---------------------------------------------------------------------------------------------------- [Node] Impl
|
||||
|
|
|
@ -76,7 +76,7 @@ impl Hash {
|
|||
Self::Giga => f * 1_000_000_000.0,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn convert(f: f64, og: Self, new: Self) -> f64 {
|
||||
match og {
|
||||
Self::Hash => match new {
|
||||
|
|
|
@ -176,12 +176,6 @@ impl Process {
|
|||
}
|
||||
}
|
||||
|
||||
// Borrow a [&str], return an owned split collection
|
||||
#[inline]
|
||||
pub fn parse_args(args: &str) -> Vec<String> {
|
||||
args.split_whitespace().map(|s| s.to_owned()).collect()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
// Convenience functions
|
||||
pub fn is_alive(&self) -> bool {
|
||||
|
|
|
@ -372,6 +372,7 @@ impl Helper {
|
|||
// This isn't actually async, a tokio runtime is unfortunately needed because [Hyper] is an async library (HTTP API calls)
|
||||
#[tokio::main]
|
||||
#[allow(clippy::await_holding_lock)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn spawn_xmrig_watchdog(
|
||||
process: Arc<Mutex<Process>>,
|
||||
gui_api: Arc<Mutex<PubXmrigApi>>,
|
||||
|
@ -458,7 +459,7 @@ impl Helper {
|
|||
*lock!(pub_api) = PubXmrigApi::new();
|
||||
*lock!(gui_api) = PubXmrigApi::new();
|
||||
// node used for process Status tab
|
||||
lock!(gui_api).node = lock!(img_xmrig).url.clone();
|
||||
lock!(gui_api).node.clone_from(&lock!(img_xmrig).url);
|
||||
// 5. Loop as watchdog
|
||||
info!("XMRig | Entering watchdog mode... woof!");
|
||||
loop {
|
||||
|
@ -797,15 +798,6 @@ pub(super) struct PrivXmrigApi {
|
|||
}
|
||||
|
||||
impl PrivXmrigApi {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
worker_id: String::new(),
|
||||
resources: Resources::new(),
|
||||
connection: Connection::new(),
|
||||
hashrate: Hashrate::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
// Send an HTTP request to XMRig's API, serialize it into [Self] and return it
|
||||
async fn request_xmrig_api(
|
||||
|
@ -892,13 +884,6 @@ impl PrivXmrigApi {
|
|||
struct Resources {
|
||||
load_average: [Option<f32>; 3],
|
||||
}
|
||||
impl Resources {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
load_average: [Some(0.0), Some(0.0), Some(0.0)],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
struct Connection {
|
||||
|
@ -906,24 +891,8 @@ struct Connection {
|
|||
accepted: u128,
|
||||
rejected: u128,
|
||||
}
|
||||
impl Connection {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
diff: 0,
|
||||
accepted: 0,
|
||||
rejected: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
|
||||
struct Hashrate {
|
||||
total: [Option<f32>; 3],
|
||||
}
|
||||
impl Hashrate {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
total: [Some(0.0), Some(0.0), Some(0.0)],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ impl Helper {
|
|||
);
|
||||
});
|
||||
}
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[tokio::main]
|
||||
async fn spawn_xvb_watchdog(
|
||||
gui_api: Arc<Mutex<PubXvbApi>>,
|
||||
|
@ -371,7 +372,7 @@ impl Helper {
|
|||
lock!(&pub_api).stats_priv.round_participate = round;
|
||||
|
||||
// verify if we are the winner of the current round
|
||||
if &lock!(pub_api).stats_pub.winner
|
||||
if lock!(pub_api).stats_pub.winner
|
||||
== Helper::head_tail_of_monero_address(&state_p2pool.address).as_str()
|
||||
{
|
||||
lock!(pub_api).stats_priv.win_current = true
|
||||
|
@ -527,6 +528,7 @@ impl Helper {
|
|||
_ => 0,
|
||||
}
|
||||
}
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn sleep_then_update_node_xmrig(
|
||||
was_instant: &tokio::time::Instant,
|
||||
spared_time: u32,
|
||||
|
@ -762,13 +764,11 @@ impl XvbNode {
|
|||
} else {
|
||||
XvbNode::Europe
|
||||
}
|
||||
} else
|
||||
// if only na is online, return it.
|
||||
if ms_na != TIMEOUT_NODE_PING && ms_eu == TIMEOUT_NODE_PING {
|
||||
} else if ms_na != TIMEOUT_NODE_PING && ms_eu == TIMEOUT_NODE_PING {
|
||||
// if only na is online, return it.
|
||||
XvbNode::NorthAmerica
|
||||
} else
|
||||
// if only eu is online, return it.
|
||||
if ms_na == TIMEOUT_NODE_PING && ms_eu != TIMEOUT_NODE_PING {
|
||||
} else if ms_na == TIMEOUT_NODE_PING && ms_eu != TIMEOUT_NODE_PING {
|
||||
// if only eu is online, return it.
|
||||
XvbNode::Europe
|
||||
} else {
|
||||
// if P2pool is returned, it means none of the two nodes are available.
|
||||
|
@ -786,7 +786,7 @@ impl XvbNode {
|
|||
// if both nodes are dead, then the state of the process must be NodesOffline
|
||||
info!("XvB node ping, all offline or ping failed, switching back to local p2pool",);
|
||||
output_console(
|
||||
&gui_api_xvb,
|
||||
gui_api_xvb,
|
||||
"XvB node ping, all offline or ping failed, switching back to local p2pool",
|
||||
);
|
||||
lock!(process_xvb).state = ProcessState::OfflineNodesAll;
|
||||
|
@ -794,7 +794,7 @@ impl XvbNode {
|
|||
// if node is up and because update_fastest is used only if token/address is valid, it means XvB process is Alive.
|
||||
info!("XvB node ping, both online and best is {}", node.url());
|
||||
output_console(
|
||||
&gui_api_xvb,
|
||||
gui_api_xvb,
|
||||
&format!("XvB node ping, {} is selected as the fastest.", node),
|
||||
);
|
||||
lock!(process_xvb).state = ProcessState::Alive;
|
||||
|
@ -861,7 +861,7 @@ impl PubXvbApi {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn signal_interrupt(
|
||||
process: Arc<Mutex<Process>>,
|
||||
start: Instant,
|
||||
|
@ -887,7 +887,7 @@ fn signal_interrupt(
|
|||
// insert the signal into output of XvB
|
||||
// This is written directly into the GUI API, because sometimes the 900ms event loop can't catch it.
|
||||
output_console(
|
||||
&gui_api,
|
||||
gui_api,
|
||||
&format!("{}XvB stopped\n{}\n", HORI_CONSOLE, HORI_CONSOLE),
|
||||
);
|
||||
debug!("XvB Watchdog | Stop SIGNAL done, breaking");
|
||||
|
|
|
@ -119,12 +119,11 @@ 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 BLUE: egui::Color32 = egui::Color32::from_rgb(100, 175, 255);
|
||||
pub const ORANGE: egui::Color32 = egui::Color32::from_rgb(255, 120, 40);
|
||||
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
|
||||
pub const WHITE: egui::Color32 = egui::Color32::WHITE;
|
||||
pub const GRAY: egui::Color32 = egui::Color32::GRAY;
|
||||
pub const LIGHT_GRAY: egui::Color32 = egui::Color32::LIGHT_GRAY;
|
||||
pub const BLACK: egui::Color32 = egui::Color32::BLACK;
|
||||
|
@ -266,7 +265,6 @@ pub const GUPAX_UPDATE: &str =
|
|||
pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup";
|
||||
pub const GUPAX_SHOULD_RESTART: &str =
|
||||
"Gupax was updated. A restart is recommended but not required";
|
||||
pub const GUPAX_UP_TO_DATE: &str = "Gupax is up-to-date";
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub const GUPAX_UPDATE_VIA_TOR: &str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
|
||||
#[cfg(target_os = "macos")] // Arti library has issues on macOS
|
||||
|
@ -305,7 +303,6 @@ pub const GUPAX_ADVANCED: &str = r#"Use advanced Gupax settings:
|
|||
- Gupax resolution sliders
|
||||
- Gupax start-up tab selector"#;
|
||||
pub const GUPAX_SELECT: &str = "Open a file explorer to select a file";
|
||||
pub const GUPAX_PATH: &str = "Use custom PATHs when looking for P2Pool/XMRig";
|
||||
pub const GUPAX_PATH_P2POOL: &str = "The location of the P2Pool binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";
|
||||
pub const GUPAX_PATH_XMRIG: &str = "The location of the XMRig binary: Both absolute and relative paths are accepted; A red [X] will appear if there is no file found at the given path";
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ use super::sudo::SudoState;
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- [ErrorState] struct
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[allow(dead_code)]
|
||||
pub enum ErrorButtons {
|
||||
YesNo,
|
||||
StayQuit,
|
||||
|
|
|
@ -127,10 +127,6 @@ impl HumanNumber {
|
|||
Self(s.to_string())
|
||||
}
|
||||
#[inline]
|
||||
pub fn to_hashrate(f: f32) -> Self {
|
||||
Self(format!("{} H/s", Self::from_f32(f)))
|
||||
}
|
||||
#[inline]
|
||||
pub fn to_percent(f: f32) -> Self {
|
||||
if f < 0.01 {
|
||||
Self("0%".to_string())
|
||||
|
@ -139,42 +135,30 @@ impl HumanNumber {
|
|||
}
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
pub fn to_percent_3_point(f: f32) -> Self {
|
||||
Self(format!("{:.3}%", f))
|
||||
}
|
||||
#[inline]
|
||||
pub fn to_percent_no_fmt(f: f32) -> Self {
|
||||
Self(format!("{}%", f))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_f64_to_percent_3_point(f: f64) -> Self {
|
||||
Self(format!("{:.3}%", f))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_f64_to_percent_6_point(f: f64) -> Self {
|
||||
Self(format!("{:.6}%", f))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_f64_to_percent_9_point(f: f64) -> Self {
|
||||
Self(format!("{:.9}%", f))
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_f64_to_percent_no_fmt(f: f64) -> Self {
|
||||
Self(format!("{}%", f))
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
pub fn from_f32(f: f32) -> Self {
|
||||
let mut buf = num_format::Buffer::new();
|
||||
buf.write_formatted(&(f as u64), &LOCALE);
|
||||
Self(buf.as_str().to_string())
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
pub fn from_f64(f: f64) -> Self {
|
||||
let mut buf = num_format::Buffer::new();
|
||||
buf.write_formatted(&(f as u128), &LOCALE);
|
||||
Self(buf.as_str().to_string())
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
pub fn from_u16(u: u16) -> Self {
|
||||
let mut buf = num_format::Buffer::new();
|
||||
buf.write_formatted(&u, &LOCALE);
|
||||
|
@ -193,6 +177,7 @@ impl HumanNumber {
|
|||
Self(buf.as_str().to_string())
|
||||
}
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
pub fn from_u128(u: u128) -> Self {
|
||||
let mut buf = num_format::Buffer::new();
|
||||
buf.write_formatted(&u, &LOCALE);
|
||||
|
@ -264,11 +249,6 @@ impl HumanNumber {
|
|||
Self(f)
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_f64_no_fmt(f: f64) -> Self {
|
||||
let f = format!("{}", f);
|
||||
Self(f)
|
||||
}
|
||||
#[inline]
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
|
|
|
@ -127,7 +127,6 @@ impl XmrigRegex {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use regex::Regex;
|
||||
|
||||
#[test]
|
||||
fn build_regexes() {
|
||||
|
|
|
@ -49,9 +49,9 @@ impl AtomicUnit {
|
|||
Self(u)
|
||||
}
|
||||
|
||||
pub const fn add_u64(self, u: u64) -> Self {
|
||||
Self(self.0 + u)
|
||||
}
|
||||
// pub const fn add_u64(self, u: u64) -> Self {
|
||||
// Self(self.0 + u)
|
||||
// }
|
||||
|
||||
pub const fn add_self(self, atomic_unit: Self) -> Self {
|
||||
Self(self.0 + atomic_unit.0)
|
||||
|
@ -69,31 +69,31 @@ impl AtomicUnit {
|
|||
self.0.to_string()
|
||||
}
|
||||
|
||||
pub fn sum_vec(vec: &Vec<Self>) -> Self {
|
||||
let mut sum = 0;
|
||||
for int in vec {
|
||||
sum += int.0;
|
||||
}
|
||||
Self(sum)
|
||||
}
|
||||
// pub fn sum_vec(vec: &Vec<Self>) -> Self {
|
||||
// let mut sum = 0;
|
||||
// for int in vec {
|
||||
// sum += int.0;
|
||||
// }
|
||||
// Self(sum)
|
||||
// }
|
||||
|
||||
pub fn from_f64(f: f64) -> Self {
|
||||
Self((f * 1_000_000_000_000.0) as u64)
|
||||
}
|
||||
|
||||
pub fn f64(&self) -> f64 {
|
||||
self.0 as f64 / 1_000_000_000_000.0
|
||||
}
|
||||
// pub fn f64(&self) -> f64 {
|
||||
// self.0 as f64 / 1_000_000_000_000.0
|
||||
// }
|
||||
|
||||
pub fn human_number_12_point(&self) -> HumanNumber {
|
||||
let f = self.0 as f64 / 1_000_000_000_000.0;
|
||||
HumanNumber::from_f64_12_point(f)
|
||||
}
|
||||
|
||||
pub fn human_number_no_fmt(&self) -> HumanNumber {
|
||||
let f = self.0 as f64 / 1_000_000_000_000.0;
|
||||
HumanNumber::from_f64_no_fmt(f)
|
||||
}
|
||||
// pub fn human_number_no_fmt(&self) -> HumanNumber {
|
||||
// let f = self.0 as f64 / 1_000_000_000_000.0;
|
||||
// HumanNumber::from_f64_no_fmt(f)
|
||||
// }
|
||||
}
|
||||
|
||||
// Displays AtomicUnit as a real XMR floating point.
|
||||
|
@ -124,11 +124,11 @@ impl PayoutOrd {
|
|||
HumanNumber::unknown(),
|
||||
)])
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub const fn from_vec(vec: Vec<(String, AtomicUnit, HumanNumber)>) -> Self {
|
||||
Self(vec)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn is_same(a: &Self, b: &Self) -> bool {
|
||||
if a.0.is_empty() && b.0.is_empty() {
|
||||
return true;
|
||||
|
@ -149,7 +149,7 @@ impl PayoutOrd {
|
|||
}
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
@ -263,12 +263,13 @@ impl PayoutOrd {
|
|||
}
|
||||
|
||||
// Takes the raw components (no wrapper types), convert them and pushes to existing [Self]
|
||||
#[cfg(test)]
|
||||
pub fn push_raw(&mut self, date: &str, atomic_unit: u64, block: u64) {
|
||||
let atomic_unit = AtomicUnit(atomic_unit);
|
||||
let block = HumanNumber::from_u64(block);
|
||||
self.0.push((date.to_string(), atomic_unit, block));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn atomic_unit_sum(&self) -> AtomicUnit {
|
||||
let mut sum: u64 = 0;
|
||||
for (_, atomic_unit, _) in &self.0 {
|
||||
|
@ -294,6 +295,7 @@ impl PayoutOrd {
|
|||
|
||||
// Returns a reversed [Iter] of the [PayoutOrd]
|
||||
// This is obviously faster than actually reordering the Vec.
|
||||
#[cfg(test)]
|
||||
pub fn rev_iter(
|
||||
&self,
|
||||
) -> std::iter::Rev<std::slice::Iter<'_, (String, AtomicUnit, HumanNumber)>> {
|
||||
|
|
Loading…
Reference in a new issue