mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-10 16:04:31 +00:00
fix: clippy non auto fixable warnings
This commit is contained in:
parent
2c7a1174b7
commit
ffceb4b298
10 changed files with 76 additions and 72 deletions
23
src/disk.rs
23
src/disk.rs
|
@ -37,6 +37,7 @@ use log::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
use std::path::Path;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
|
@ -179,8 +180,8 @@ pub fn set_unix_660_perms(path: &PathBuf) -> Result<(), TomlError> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_gupax_p2pool_path(os_data_path: &PathBuf) -> PathBuf {
|
pub fn get_gupax_p2pool_path(os_data_path: &Path) -> PathBuf {
|
||||||
let mut gupax_p2pool_dir = os_data_path.clone();
|
let mut gupax_p2pool_dir = os_data_path.to_path_buf();
|
||||||
gupax_p2pool_dir.push(GUPAX_P2POOL_API_DIRECTORY);
|
gupax_p2pool_dir.push(GUPAX_P2POOL_API_DIRECTORY);
|
||||||
gupax_p2pool_dir
|
gupax_p2pool_dir
|
||||||
}
|
}
|
||||||
|
@ -728,10 +729,10 @@ impl GupaxP2poolApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fill_paths(&mut self, gupax_p2pool_dir: &PathBuf) {
|
pub fn fill_paths(&mut self, gupax_p2pool_dir: &Path) {
|
||||||
let mut path_log = gupax_p2pool_dir.clone();
|
let mut path_log = gupax_p2pool_dir.to_path_buf();
|
||||||
let mut path_payout = gupax_p2pool_dir.clone();
|
let mut path_payout = gupax_p2pool_dir.to_path_buf();
|
||||||
let mut path_xmr = gupax_p2pool_dir.clone();
|
let mut path_xmr = gupax_p2pool_dir.to_path_buf();
|
||||||
path_log.push(GUPAX_P2POOL_API_LOG);
|
path_log.push(GUPAX_P2POOL_API_LOG);
|
||||||
path_payout.push(GUPAX_P2POOL_API_PAYOUT);
|
path_payout.push(GUPAX_P2POOL_API_PAYOUT);
|
||||||
path_xmr.push(GUPAX_P2POOL_API_XMR);
|
path_xmr.push(GUPAX_P2POOL_API_XMR);
|
||||||
|
@ -743,10 +744,10 @@ impl GupaxP2poolApi {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_all_files(gupax_p2pool_dir: &PathBuf) -> Result<(), TomlError> {
|
pub fn create_all_files(gupax_p2pool_dir: &Path) -> Result<(), TomlError> {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
for file in GUPAX_P2POOL_API_FILE_ARRAY {
|
for file in GUPAX_P2POOL_API_FILE_ARRAY {
|
||||||
let mut path = gupax_p2pool_dir.clone();
|
let mut path = gupax_p2pool_dir.to_path_buf();
|
||||||
path.push(file);
|
path.push(file);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
info!(
|
info!(
|
||||||
|
@ -1061,6 +1062,7 @@ impl Display for PayoutView {
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- [Hash] enum for [Status/P2Pool]
|
//---------------------------------------------------------------------------------------------------- [Hash] enum for [Status/P2Pool]
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub enum Hash {
|
pub enum Hash {
|
||||||
Hash,
|
Hash,
|
||||||
Kilo,
|
Kilo,
|
||||||
|
@ -1229,8 +1231,7 @@ pub struct Xmrig {
|
||||||
pub selected_port: String,
|
pub selected_port: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)]
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Xvb {
|
pub struct Xvb {
|
||||||
pub token: u32,
|
pub token: u32,
|
||||||
}
|
}
|
||||||
|
@ -1342,8 +1343,6 @@ impl Default for Xmrig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl Default for Version {
|
impl Default for Version {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -71,6 +71,7 @@ pub enum Ratio {
|
||||||
//---------------------------------------------------------------------------------------------------- Gupax
|
//---------------------------------------------------------------------------------------------------- Gupax
|
||||||
impl crate::disk::Gupax {
|
impl crate::disk::Gupax {
|
||||||
#[inline(always)] // called once
|
#[inline(always)] // called once
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn show(
|
pub fn show(
|
||||||
&mut self,
|
&mut self,
|
||||||
og: &Arc<Mutex<State>>,
|
og: &Arc<Mutex<State>>,
|
||||||
|
|
|
@ -38,6 +38,7 @@ use crate::regex::{P2POOL_REGEX, XMRIG_REGEX};
|
||||||
use crate::{constants::*, human::*, macros::*, xmr::*, GupaxP2poolApi, RemoteNode, SudoState};
|
use crate::{constants::*, human::*, macros::*, xmr::*, GupaxP2poolApi, RemoteNode, SudoState};
|
||||||
use log::*;
|
use log::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::path::Path;
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Write,
|
fmt::Write,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
|
@ -262,6 +263,7 @@ impl std::fmt::Display for ProcessName {
|
||||||
//---------------------------------------------------------------------------------------------------- [Helper]
|
//---------------------------------------------------------------------------------------------------- [Helper]
|
||||||
impl Helper {
|
impl Helper {
|
||||||
//---------------------------------------------------------------------------------------------------- General Functions
|
//---------------------------------------------------------------------------------------------------- General Functions
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
instant: std::time::Instant,
|
instant: std::time::Instant,
|
||||||
pub_sys: Arc<Mutex<Sys>>,
|
pub_sys: Arc<Mutex<Sys>>,
|
||||||
|
@ -408,7 +410,7 @@ impl Helper {
|
||||||
|
|
||||||
// Read P2Pool/XMRig's API file to a [String].
|
// Read P2Pool/XMRig's API file to a [String].
|
||||||
fn path_to_string(
|
fn path_to_string(
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
name: ProcessName,
|
name: ProcessName,
|
||||||
) -> std::result::Result<String, std::io::Error> {
|
) -> std::result::Result<String, std::io::Error> {
|
||||||
match std::fs::read_to_string(path) {
|
match std::fs::read_to_string(path) {
|
||||||
|
@ -437,7 +439,7 @@ impl Helper {
|
||||||
pub fn restart_p2pool(
|
pub fn restart_p2pool(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::P2pool,
|
state: &crate::disk::P2pool,
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
backup_hosts: Option<Vec<crate::Node>>,
|
backup_hosts: Option<Vec<crate::Node>>,
|
||||||
) {
|
) {
|
||||||
info!("P2Pool | Attempting to restart...");
|
info!("P2Pool | Attempting to restart...");
|
||||||
|
@ -446,7 +448,7 @@ impl Helper {
|
||||||
|
|
||||||
let helper = Arc::clone(helper);
|
let helper = Arc::clone(helper);
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
// This thread lives to wait, start p2pool then die.
|
// This thread lives to wait, start p2pool then die.
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
while lock2!(helper, p2pool).is_alive() {
|
while lock2!(helper, p2pool).is_alive() {
|
||||||
|
@ -466,7 +468,7 @@ impl Helper {
|
||||||
pub fn start_p2pool(
|
pub fn start_p2pool(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::P2pool,
|
state: &crate::disk::P2pool,
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
backup_hosts: Option<Vec<crate::Node>>,
|
backup_hosts: Option<Vec<crate::Node>>,
|
||||||
) {
|
) {
|
||||||
lock2!(helper, p2pool).state = ProcessState::Middle;
|
lock2!(helper, p2pool).state = ProcessState::Middle;
|
||||||
|
@ -488,7 +490,7 @@ impl Helper {
|
||||||
let gui_api = Arc::clone(&lock!(helper).gui_api_p2pool);
|
let gui_api = Arc::clone(&lock!(helper).gui_api_p2pool);
|
||||||
let pub_api = Arc::clone(&lock!(helper).pub_api_p2pool);
|
let pub_api = Arc::clone(&lock!(helper).pub_api_p2pool);
|
||||||
let gupax_p2pool_api = Arc::clone(&lock!(helper).gupax_p2pool_api);
|
let gupax_p2pool_api = Arc::clone(&lock!(helper).gupax_p2pool_api);
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
Self::spawn_p2pool_watchdog(
|
Self::spawn_p2pool_watchdog(
|
||||||
process,
|
process,
|
||||||
|
@ -523,11 +525,11 @@ impl Helper {
|
||||||
pub fn build_p2pool_args_and_mutate_img(
|
pub fn build_p2pool_args_and_mutate_img(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::P2pool,
|
state: &crate::disk::P2pool,
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
backup_hosts: Option<Vec<crate::Node>>,
|
backup_hosts: Option<Vec<crate::Node>>,
|
||||||
) -> (Vec<String>, PathBuf, PathBuf, PathBuf) {
|
) -> (Vec<String>, PathBuf, PathBuf, PathBuf) {
|
||||||
let mut args = Vec::with_capacity(500);
|
let mut args = Vec::with_capacity(500);
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
let mut api_path = path;
|
let mut api_path = path;
|
||||||
api_path.pop();
|
api_path.pop();
|
||||||
|
|
||||||
|
@ -684,6 +686,7 @@ impl Helper {
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
// The P2Pool watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
// The P2Pool watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn spawn_p2pool_watchdog(
|
fn spawn_p2pool_watchdog(
|
||||||
process: Arc<Mutex<Process>>,
|
process: Arc<Mutex<Process>>,
|
||||||
gui_api: Arc<Mutex<PubP2poolApi>>,
|
gui_api: Arc<Mutex<PubP2poolApi>>,
|
||||||
|
@ -1039,7 +1042,7 @@ impl Helper {
|
||||||
pub fn restart_xmrig(
|
pub fn restart_xmrig(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::Xmrig,
|
state: &crate::disk::Xmrig,
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
sudo: Arc<Mutex<SudoState>>,
|
sudo: Arc<Mutex<SudoState>>,
|
||||||
) {
|
) {
|
||||||
info!("XMRig | Attempting to restart...");
|
info!("XMRig | Attempting to restart...");
|
||||||
|
@ -1048,7 +1051,7 @@ impl Helper {
|
||||||
|
|
||||||
let helper = Arc::clone(helper);
|
let helper = Arc::clone(helper);
|
||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
// This thread lives to wait, start xmrig then die.
|
// This thread lives to wait, start xmrig then die.
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
while lock2!(helper, xmrig).state != ProcessState::Waiting {
|
while lock2!(helper, xmrig).state != ProcessState::Waiting {
|
||||||
|
@ -1067,7 +1070,7 @@ impl Helper {
|
||||||
pub fn start_xmrig(
|
pub fn start_xmrig(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::Xmrig,
|
state: &crate::disk::Xmrig,
|
||||||
path: &std::path::PathBuf,
|
path: &Path,
|
||||||
sudo: Arc<Mutex<SudoState>>,
|
sudo: Arc<Mutex<SudoState>>,
|
||||||
) {
|
) {
|
||||||
lock2!(helper, xmrig).state = ProcessState::Middle;
|
lock2!(helper, xmrig).state = ProcessState::Middle;
|
||||||
|
@ -1082,7 +1085,7 @@ impl Helper {
|
||||||
let process = Arc::clone(&lock!(helper).xmrig);
|
let process = Arc::clone(&lock!(helper).xmrig);
|
||||||
let gui_api = Arc::clone(&lock!(helper).gui_api_xmrig);
|
let gui_api = Arc::clone(&lock!(helper).gui_api_xmrig);
|
||||||
let pub_api = Arc::clone(&lock!(helper).pub_api_xmrig);
|
let pub_api = Arc::clone(&lock!(helper).pub_api_xmrig);
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
Self::spawn_xmrig_watchdog(process, gui_api, pub_api, args, path, sudo, api_ip_port);
|
Self::spawn_xmrig_watchdog(process, gui_api, pub_api, args, path, sudo, api_ip_port);
|
||||||
});
|
});
|
||||||
|
@ -1096,12 +1099,12 @@ impl Helper {
|
||||||
pub fn build_xmrig_args_and_mutate_img(
|
pub fn build_xmrig_args_and_mutate_img(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
state: &crate::disk::Xmrig,
|
state: &crate::disk::Xmrig,
|
||||||
path: &std::path::PathBuf,
|
path: &std::path::Path,
|
||||||
) -> (Vec<String>, String) {
|
) -> (Vec<String>, String) {
|
||||||
let mut args = Vec::with_capacity(500);
|
let mut args = Vec::with_capacity(500);
|
||||||
let mut api_ip = String::with_capacity(15);
|
let mut api_ip = String::with_capacity(15);
|
||||||
let mut api_port = String::with_capacity(5);
|
let mut api_port = String::with_capacity(5);
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
// The actual binary we're executing is [sudo], technically
|
// The actual binary we're executing is [sudo], technically
|
||||||
// the XMRig path is just an argument to sudo, so add it.
|
// the XMRig path is just an argument to sudo, so add it.
|
||||||
// Before that though, add the ["--prompt"] flag and set it
|
// Before that though, add the ["--prompt"] flag and set it
|
||||||
|
@ -1246,6 +1249,7 @@ impl Helper {
|
||||||
// The XMRig watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
// The XMRig watchdog. Spawns 1 OS thread for reading a PTY (STDOUT+STDERR), and combines the [Child] with a PTY so STDIN actually works.
|
||||||
// This isn't actually async, a tokio runtime is unfortunately needed because [Hyper] is an async library (HTTP API calls)
|
// This isn't actually async, a tokio runtime is unfortunately needed because [Hyper] is an async library (HTTP API calls)
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
#[allow(clippy::await_holding_lock)]
|
||||||
async fn spawn_xmrig_watchdog(
|
async fn spawn_xmrig_watchdog(
|
||||||
process: Arc<Mutex<Process>>,
|
process: Arc<Mutex<Process>>,
|
||||||
gui_api: Arc<Mutex<PubXmrigApi>>,
|
gui_api: Arc<Mutex<PubXmrigApi>>,
|
||||||
|
@ -1442,6 +1446,7 @@ impl Helper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check vector of user input
|
// Check vector of user input
|
||||||
|
{
|
||||||
let mut lock = lock!(process);
|
let mut lock = lock!(process);
|
||||||
if !lock.input.is_empty() {
|
if !lock.input.is_empty() {
|
||||||
let input = std::mem::take(&mut lock.input);
|
let input = std::mem::take(&mut lock.input);
|
||||||
|
@ -1467,14 +1472,13 @@ impl Helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drop(lock);
|
}
|
||||||
|
|
||||||
// Check if logs need resetting
|
// Check if logs need resetting
|
||||||
debug!("XMRig Watchdog | Attempting GUI log reset check");
|
debug!("XMRig Watchdog | Attempting GUI log reset check");
|
||||||
|
{
|
||||||
let mut lock = lock!(gui_api);
|
let mut lock = lock!(gui_api);
|
||||||
Self::check_reset_gui_output(&mut lock.output, ProcessName::Xmrig);
|
Self::check_reset_gui_output(&mut lock.output, ProcessName::Xmrig);
|
||||||
drop(lock);
|
}
|
||||||
|
|
||||||
// Always update from output
|
// Always update from output
|
||||||
debug!("XMRig Watchdog | Starting [update_from_output()]");
|
debug!("XMRig Watchdog | Starting [update_from_output()]");
|
||||||
PubXmrigApi::update_from_output(
|
PubXmrigApi::update_from_output(
|
||||||
|
@ -1560,6 +1564,7 @@ impl Helper {
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
// The "helper" thread. Syncs data between threads here and the GUI.
|
// The "helper" thread. Syncs data between threads here and the GUI.
|
||||||
|
#[allow(clippy::await_holding_lock)]
|
||||||
pub fn spawn_helper(
|
pub fn spawn_helper(
|
||||||
helper: &Arc<Mutex<Self>>,
|
helper: &Arc<Mutex<Self>>,
|
||||||
mut sysinfo: sysinfo::System,
|
mut sysinfo: sysinfo::System,
|
||||||
|
|
|
@ -923,9 +923,9 @@ fn init_logger(now: Instant) {
|
||||||
let dimmed = Style::new().dimmed();
|
let dimmed = Style::new().dimmed();
|
||||||
writeln!(
|
writeln!(
|
||||||
buf,
|
buf,
|
||||||
"{level_style}[{}]{level_style:#} [{dimmed}{}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
"{level_style}[{}]{level_style:#} [{dimmed}{:.3}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
||||||
level,
|
level,
|
||||||
format!("{:.3}", now.elapsed().as_secs_f32()),
|
now.elapsed().as_secs_f32(),
|
||||||
record.file().unwrap_or("???"),
|
record.file().unwrap_or("???"),
|
||||||
record.line().unwrap_or(0),
|
record.line().unwrap_or(0),
|
||||||
record.args(),
|
record.args(),
|
||||||
|
|
|
@ -27,6 +27,7 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
impl crate::disk::P2pool {
|
impl crate::disk::P2pool {
|
||||||
#[inline(always)] // called once
|
#[inline(always)] // called once
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn show(
|
pub fn show(
|
||||||
&mut self,
|
&mut self,
|
||||||
node_vec: &mut Vec<(String, Node)>,
|
node_vec: &mut Vec<(String, Node)>,
|
||||||
|
@ -424,8 +425,7 @@ impl crate::disk::P2pool {
|
||||||
debug!("P2Pool Tab | Rendering [Node List]");
|
debug!("P2Pool Tab | Rendering [Node List]");
|
||||||
let text = RichText::new(format!("{}. {}", self.selected_index+1, self.selected_name));
|
let text = RichText::new(format!("{}. {}", self.selected_index+1, self.selected_name));
|
||||||
ComboBox::from_id_source("manual_nodes").selected_text(text).width(width).show_ui(ui, |ui| {
|
ComboBox::from_id_source("manual_nodes").selected_text(text).width(width).show_ui(ui, |ui| {
|
||||||
let mut n = 0;
|
for (n, (name, node)) in node_vec.iter().enumerate() {
|
||||||
for (name, node) in node_vec.iter() {
|
|
||||||
let text = RichText::new(format!("{}. {}\n IP: {}\n RPC: {}\n ZMQ: {}", n+1, name, node.ip, node.rpc, node.zmq));
|
let text = RichText::new(format!("{}. {}\n IP: {}\n RPC: {}\n ZMQ: {}", n+1, name, node.ip, node.rpc, node.zmq));
|
||||||
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
||||||
self.selected_index = n;
|
self.selected_index = n;
|
||||||
|
@ -439,7 +439,6 @@ impl crate::disk::P2pool {
|
||||||
self.rpc = node.rpc;
|
self.rpc = node.rpc;
|
||||||
self.zmq = node.zmq;
|
self.zmq = node.zmq;
|
||||||
}
|
}
|
||||||
n += 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// [Add/Save]
|
// [Add/Save]
|
||||||
|
|
|
@ -20,13 +20,15 @@ use crate::{
|
||||||
ImgXmrig, PayoutView, PubP2poolApi, PubXmrigApi, Submenu, Sys,
|
ImgXmrig, PayoutView, PubP2poolApi, PubXmrigApi, Submenu, Sys,
|
||||||
};
|
};
|
||||||
use egui::{
|
use egui::{
|
||||||
Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle, TextStyle::Name,
|
Hyperlink, Label, ProgressBar, RichText, SelectableLabel, Slider, Spinner, TextEdit, TextStyle,
|
||||||
|
TextStyle::Name,
|
||||||
};
|
};
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
impl crate::disk::Status {
|
impl crate::disk::Status {
|
||||||
#[inline(always)] // called once
|
#[inline(always)] // called once
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn show(
|
pub fn show(
|
||||||
&mut self,
|
&mut self,
|
||||||
sys: &Arc<Mutex<Sys>>,
|
sys: &Arc<Mutex<Sys>>,
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::{constants::*, disk::Xmrig, macros::*, Helper, ProcessSignal};
|
||||||
use log::*;
|
use log::*;
|
||||||
use std::{
|
use std::{
|
||||||
io::Write,
|
io::Write,
|
||||||
path::PathBuf,
|
path::Path,
|
||||||
process::*,
|
process::*,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
thread,
|
thread,
|
||||||
|
@ -111,11 +111,11 @@ impl SudoState {
|
||||||
state: Arc<Mutex<Self>>,
|
state: Arc<Mutex<Self>>,
|
||||||
helper: &Arc<Mutex<Helper>>,
|
helper: &Arc<Mutex<Helper>>,
|
||||||
xmrig: &Xmrig,
|
xmrig: &Xmrig,
|
||||||
path: &PathBuf,
|
path: &Path,
|
||||||
) {
|
) {
|
||||||
let helper = Arc::clone(helper);
|
let helper = Arc::clone(helper);
|
||||||
let xmrig = xmrig.clone();
|
let xmrig = xmrig.clone();
|
||||||
let path = path.clone();
|
let path = path.to_path_buf();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
// Set to testing
|
// Set to testing
|
||||||
lock!(state).testing = true;
|
lock!(state).testing = true;
|
||||||
|
|
|
@ -521,6 +521,7 @@ impl Update {
|
||||||
// 3. if current == version, remove from vec
|
// 3. if current == version, remove from vec
|
||||||
// 4. loop over vec, download links
|
// 4. loop over vec, download links
|
||||||
// 5. extract, upgrade
|
// 5. extract, upgrade
|
||||||
|
#[allow(clippy::await_holding_lock)]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn start(
|
pub async fn start(
|
||||||
update: Arc<Mutex<Self>>,
|
update: Arc<Mutex<Self>>,
|
||||||
|
|
12
src/xmr.rs
12
src/xmr.rs
|
@ -81,16 +81,16 @@ impl AtomicUnit {
|
||||||
Self((f * 1_000_000_000_000.0) as u64)
|
Self((f * 1_000_000_000_000.0) as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_f64(&self) -> f64 {
|
pub fn f64(&self) -> f64 {
|
||||||
self.0 as f64 / 1_000_000_000_000.0
|
self.0 as f64 / 1_000_000_000_000.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_human_number_12_point(&self) -> HumanNumber {
|
pub fn human_number_12_point(&self) -> HumanNumber {
|
||||||
let f = self.0 as f64 / 1_000_000_000_000.0;
|
let f = self.0 as f64 / 1_000_000_000_000.0;
|
||||||
HumanNumber::from_f64_12_point(f)
|
HumanNumber::from_f64_12_point(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_human_number_no_fmt(&self) -> HumanNumber {
|
pub fn human_number_no_fmt(&self) -> HumanNumber {
|
||||||
let f = self.0 as f64 / 1_000_000_000_000.0;
|
let f = self.0 as f64 / 1_000_000_000_000.0;
|
||||||
HumanNumber::from_f64_no_fmt(f)
|
HumanNumber::from_f64_no_fmt(f)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ impl AtomicUnit {
|
||||||
// Displays AtomicUnit as a real XMR floating point.
|
// Displays AtomicUnit as a real XMR floating point.
|
||||||
impl std::fmt::Display for AtomicUnit {
|
impl std::fmt::Display for AtomicUnit {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
write!(f, "{}", Self::to_human_number_12_point(self))
|
write!(f, "{}", Self::human_number_12_point(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +136,7 @@ impl PayoutOrd {
|
||||||
if a.0.len() != b.0.len() {
|
if a.0.len() != b.0.len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let mut n = 0;
|
for (n, (date, atomic_unit, block)) in a.0.iter().enumerate() {
|
||||||
for (date, atomic_unit, block) in &a.0 {
|
|
||||||
if *date != b.0[n].0 {
|
if *date != b.0[n].0 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +146,6 @@ impl PayoutOrd {
|
||||||
if *block != b.0[n].2 {
|
if *block != b.0[n].2 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
n += 1;
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
impl crate::disk::Xmrig {
|
impl crate::disk::Xmrig {
|
||||||
#[inline(always)] // called once
|
#[inline(always)] // called once
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn show(
|
pub fn show(
|
||||||
&mut self,
|
&mut self,
|
||||||
pool_vec: &mut Vec<(String, Pool)>,
|
pool_vec: &mut Vec<(String, Pool)>,
|
||||||
|
@ -282,8 +283,7 @@ impl crate::disk::Xmrig {
|
||||||
debug!("XMRig Tab | Rendering [Node List] ComboBox");
|
debug!("XMRig Tab | Rendering [Node List] ComboBox");
|
||||||
let text = RichText::new(format!("{}. {}", self.selected_index+1, self.selected_name));
|
let text = RichText::new(format!("{}. {}", self.selected_index+1, self.selected_name));
|
||||||
ComboBox::from_id_source("manual_pool").selected_text(text).width(width).show_ui(ui, |ui| {
|
ComboBox::from_id_source("manual_pool").selected_text(text).width(width).show_ui(ui, |ui| {
|
||||||
let mut n = 0;
|
for (n, (name, pool)) in pool_vec.iter().enumerate() {
|
||||||
for (name, pool) in pool_vec.iter() {
|
|
||||||
let text = format!("{}. {}\n IP: {}\n Port: {}\n Rig: {}", n+1, name, pool.ip, pool.port, pool.rig);
|
let text = format!("{}. {}\n IP: {}\n Port: {}\n Rig: {}", n+1, name, pool.ip, pool.port, pool.rig);
|
||||||
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
if ui.add(SelectableLabel::new(self.selected_name == *name, text)).clicked() {
|
||||||
self.selected_index = n;
|
self.selected_index = n;
|
||||||
|
@ -297,7 +297,6 @@ impl crate::disk::Xmrig {
|
||||||
self.ip = pool.ip;
|
self.ip = pool.ip;
|
||||||
self.port = pool.port;
|
self.port = pool.port;
|
||||||
}
|
}
|
||||||
n += 1;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// [Add/Save]
|
// [Add/Save]
|
||||||
|
|
Loading…
Reference in a new issue