mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 22:59:27 +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};
|
||||
#[cfg(target_family = "unix")]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
fmt::Display,
|
||||
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 {
|
||||
let mut gupax_p2pool_dir = os_data_path.clone();
|
||||
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);
|
||||
gupax_p2pool_dir
|
||||
}
|
||||
|
@ -728,10 +729,10 @@ impl GupaxP2poolApi {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fill_paths(&mut self, gupax_p2pool_dir: &PathBuf) {
|
||||
let mut path_log = gupax_p2pool_dir.clone();
|
||||
let mut path_payout = gupax_p2pool_dir.clone();
|
||||
let mut path_xmr = gupax_p2pool_dir.clone();
|
||||
pub fn fill_paths(&mut self, gupax_p2pool_dir: &Path) {
|
||||
let mut path_log = gupax_p2pool_dir.to_path_buf();
|
||||
let mut path_payout = gupax_p2pool_dir.to_path_buf();
|
||||
let mut path_xmr = gupax_p2pool_dir.to_path_buf();
|
||||
path_log.push(GUPAX_P2POOL_API_LOG);
|
||||
path_payout.push(GUPAX_P2POOL_API_PAYOUT);
|
||||
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;
|
||||
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);
|
||||
if path.exists() {
|
||||
info!(
|
||||
|
@ -1061,6 +1062,7 @@ impl Display for PayoutView {
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- [Hash] enum for [Status/P2Pool]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum Hash {
|
||||
Hash,
|
||||
Kilo,
|
||||
|
@ -1229,8 +1231,7 @@ pub struct Xmrig {
|
|||
pub selected_port: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
|
||||
#[derive(Default)]
|
||||
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)]
|
||||
pub struct Xvb {
|
||||
pub token: u32,
|
||||
}
|
||||
|
@ -1342,8 +1343,6 @@ impl Default for Xmrig {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Default for Version {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
@ -71,6 +71,7 @@ pub enum Ratio {
|
|||
//---------------------------------------------------------------------------------------------------- Gupax
|
||||
impl crate::disk::Gupax {
|
||||
#[inline(always)] // called once
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn show(
|
||||
&mut self,
|
||||
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 log::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
fmt::Write,
|
||||
path::PathBuf,
|
||||
|
@ -262,6 +263,7 @@ impl std::fmt::Display for ProcessName {
|
|||
//---------------------------------------------------------------------------------------------------- [Helper]
|
||||
impl Helper {
|
||||
//---------------------------------------------------------------------------------------------------- General Functions
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
instant: std::time::Instant,
|
||||
pub_sys: Arc<Mutex<Sys>>,
|
||||
|
@ -408,7 +410,7 @@ impl Helper {
|
|||
|
||||
// Read P2Pool/XMRig's API file to a [String].
|
||||
fn path_to_string(
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
name: ProcessName,
|
||||
) -> std::result::Result<String, std::io::Error> {
|
||||
match std::fs::read_to_string(path) {
|
||||
|
@ -437,7 +439,7 @@ impl Helper {
|
|||
pub fn restart_p2pool(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::P2pool,
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
backup_hosts: Option<Vec<crate::Node>>,
|
||||
) {
|
||||
info!("P2Pool | Attempting to restart...");
|
||||
|
@ -446,7 +448,7 @@ impl Helper {
|
|||
|
||||
let helper = Arc::clone(helper);
|
||||
let state = state.clone();
|
||||
let path = path.clone();
|
||||
let path = path.to_path_buf();
|
||||
// This thread lives to wait, start p2pool then die.
|
||||
thread::spawn(move || {
|
||||
while lock2!(helper, p2pool).is_alive() {
|
||||
|
@ -466,7 +468,7 @@ impl Helper {
|
|||
pub fn start_p2pool(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::P2pool,
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
backup_hosts: Option<Vec<crate::Node>>,
|
||||
) {
|
||||
lock2!(helper, p2pool).state = ProcessState::Middle;
|
||||
|
@ -488,7 +490,7 @@ impl Helper {
|
|||
let gui_api = Arc::clone(&lock!(helper).gui_api_p2pool);
|
||||
let pub_api = Arc::clone(&lock!(helper).pub_api_p2pool);
|
||||
let gupax_p2pool_api = Arc::clone(&lock!(helper).gupax_p2pool_api);
|
||||
let path = path.clone();
|
||||
let path = path.to_path_buf();
|
||||
thread::spawn(move || {
|
||||
Self::spawn_p2pool_watchdog(
|
||||
process,
|
||||
|
@ -523,11 +525,11 @@ impl Helper {
|
|||
pub fn build_p2pool_args_and_mutate_img(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::P2pool,
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
backup_hosts: Option<Vec<crate::Node>>,
|
||||
) -> (Vec<String>, PathBuf, PathBuf, PathBuf) {
|
||||
let mut args = Vec::with_capacity(500);
|
||||
let path = path.clone();
|
||||
let path = path.to_path_buf();
|
||||
let mut api_path = path;
|
||||
api_path.pop();
|
||||
|
||||
|
@ -684,6 +686,7 @@ impl Helper {
|
|||
#[cold]
|
||||
#[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.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn spawn_p2pool_watchdog(
|
||||
process: Arc<Mutex<Process>>,
|
||||
gui_api: Arc<Mutex<PubP2poolApi>>,
|
||||
|
@ -1039,7 +1042,7 @@ impl Helper {
|
|||
pub fn restart_xmrig(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::Xmrig,
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
sudo: Arc<Mutex<SudoState>>,
|
||||
) {
|
||||
info!("XMRig | Attempting to restart...");
|
||||
|
@ -1048,7 +1051,7 @@ impl Helper {
|
|||
|
||||
let helper = Arc::clone(helper);
|
||||
let state = state.clone();
|
||||
let path = path.clone();
|
||||
let path = path.to_path_buf();
|
||||
// This thread lives to wait, start xmrig then die.
|
||||
thread::spawn(move || {
|
||||
while lock2!(helper, xmrig).state != ProcessState::Waiting {
|
||||
|
@ -1067,7 +1070,7 @@ impl Helper {
|
|||
pub fn start_xmrig(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::Xmrig,
|
||||
path: &std::path::PathBuf,
|
||||
path: &Path,
|
||||
sudo: Arc<Mutex<SudoState>>,
|
||||
) {
|
||||
lock2!(helper, xmrig).state = ProcessState::Middle;
|
||||
|
@ -1082,7 +1085,7 @@ impl Helper {
|
|||
let process = Arc::clone(&lock!(helper).xmrig);
|
||||
let gui_api = Arc::clone(&lock!(helper).gui_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 || {
|
||||
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(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
state: &crate::disk::Xmrig,
|
||||
path: &std::path::PathBuf,
|
||||
path: &std::path::Path,
|
||||
) -> (Vec<String>, String) {
|
||||
let mut args = Vec::with_capacity(500);
|
||||
let mut api_ip = String::with_capacity(15);
|
||||
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 XMRig path is just an argument to sudo, so add 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.
|
||||
// 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)]
|
||||
async fn spawn_xmrig_watchdog(
|
||||
process: Arc<Mutex<Process>>,
|
||||
gui_api: Arc<Mutex<PubXmrigApi>>,
|
||||
|
@ -1442,6 +1446,7 @@ impl Helper {
|
|||
}
|
||||
|
||||
// Check vector of user input
|
||||
{
|
||||
let mut lock = lock!(process);
|
||||
if !lock.input.is_empty() {
|
||||
let input = std::mem::take(&mut lock.input);
|
||||
|
@ -1467,14 +1472,13 @@ impl Helper {
|
|||
}
|
||||
}
|
||||
}
|
||||
drop(lock);
|
||||
|
||||
}
|
||||
// Check if logs need resetting
|
||||
debug!("XMRig Watchdog | Attempting GUI log reset check");
|
||||
{
|
||||
let mut lock = lock!(gui_api);
|
||||
Self::check_reset_gui_output(&mut lock.output, ProcessName::Xmrig);
|
||||
drop(lock);
|
||||
|
||||
}
|
||||
// Always update from output
|
||||
debug!("XMRig Watchdog | Starting [update_from_output()]");
|
||||
PubXmrigApi::update_from_output(
|
||||
|
@ -1560,6 +1564,7 @@ impl Helper {
|
|||
#[cold]
|
||||
#[inline(never)]
|
||||
// The "helper" thread. Syncs data between threads here and the GUI.
|
||||
#[allow(clippy::await_holding_lock)]
|
||||
pub fn spawn_helper(
|
||||
helper: &Arc<Mutex<Self>>,
|
||||
mut sysinfo: sysinfo::System,
|
||||
|
|
|
@ -923,9 +923,9 @@ fn init_logger(now: Instant) {
|
|||
let dimmed = Style::new().dimmed();
|
||||
writeln!(
|
||||
buf,
|
||||
"{level_style}[{}]{level_style:#} [{dimmed}{}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
||||
"{level_style}[{}]{level_style:#} [{dimmed}{:.3}{dimmed:#}] [{dimmed}{}{dimmed:#}:{dimmed}{}{dimmed:#}] {}",
|
||||
level,
|
||||
format!("{:.3}", now.elapsed().as_secs_f32()),
|
||||
now.elapsed().as_secs_f32(),
|
||||
record.file().unwrap_or("???"),
|
||||
record.line().unwrap_or(0),
|
||||
record.args(),
|
||||
|
|
|
@ -27,6 +27,7 @@ use std::sync::{Arc, Mutex};
|
|||
|
||||
impl crate::disk::P2pool {
|
||||
#[inline(always)] // called once
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn show(
|
||||
&mut self,
|
||||
node_vec: &mut Vec<(String, Node)>,
|
||||
|
@ -424,8 +425,7 @@ impl crate::disk::P2pool {
|
|||
debug!("P2Pool Tab | Rendering [Node List]");
|
||||
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| {
|
||||
let mut n = 0;
|
||||
for (name, node) in node_vec.iter() {
|
||||
for (n, (name, node)) in node_vec.iter().enumerate() {
|
||||
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() {
|
||||
self.selected_index = n;
|
||||
|
@ -439,7 +439,6 @@ impl crate::disk::P2pool {
|
|||
self.rpc = node.rpc;
|
||||
self.zmq = node.zmq;
|
||||
}
|
||||
n += 1;
|
||||
}
|
||||
});
|
||||
// [Add/Save]
|
||||
|
|
|
@ -20,13 +20,15 @@ use crate::{
|
|||
ImgXmrig, PayoutView, PubP2poolApi, PubXmrigApi, Submenu, Sys,
|
||||
};
|
||||
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 std::sync::{Arc, Mutex};
|
||||
|
||||
impl crate::disk::Status {
|
||||
#[inline(always)] // called once
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn show(
|
||||
&mut self,
|
||||
sys: &Arc<Mutex<Sys>>,
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::{constants::*, disk::Xmrig, macros::*, Helper, ProcessSignal};
|
|||
use log::*;
|
||||
use std::{
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
path::Path,
|
||||
process::*,
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
|
@ -111,11 +111,11 @@ impl SudoState {
|
|||
state: Arc<Mutex<Self>>,
|
||||
helper: &Arc<Mutex<Helper>>,
|
||||
xmrig: &Xmrig,
|
||||
path: &PathBuf,
|
||||
path: &Path,
|
||||
) {
|
||||
let helper = Arc::clone(helper);
|
||||
let xmrig = xmrig.clone();
|
||||
let path = path.clone();
|
||||
let path = path.to_path_buf();
|
||||
thread::spawn(move || {
|
||||
// Set to testing
|
||||
lock!(state).testing = true;
|
||||
|
|
|
@ -521,6 +521,7 @@ impl Update {
|
|||
// 3. if current == version, remove from vec
|
||||
// 4. loop over vec, download links
|
||||
// 5. extract, upgrade
|
||||
#[allow(clippy::await_holding_lock)]
|
||||
#[tokio::main]
|
||||
pub async fn start(
|
||||
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)
|
||||
}
|
||||
|
||||
pub fn to_f64(&self) -> f64 {
|
||||
pub fn f64(&self) -> f64 {
|
||||
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;
|
||||
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;
|
||||
HumanNumber::from_f64_no_fmt(f)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ impl AtomicUnit {
|
|||
// Displays AtomicUnit as a real XMR floating point.
|
||||
impl std::fmt::Display for AtomicUnit {
|
||||
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() {
|
||||
return false;
|
||||
}
|
||||
let mut n = 0;
|
||||
for (date, atomic_unit, block) in &a.0 {
|
||||
for (n, (date, atomic_unit, block)) in a.0.iter().enumerate() {
|
||||
if *date != b.0[n].0 {
|
||||
return false;
|
||||
}
|
||||
|
@ -147,7 +146,6 @@ impl PayoutOrd {
|
|||
if *block != b.0[n].2 {
|
||||
return false;
|
||||
}
|
||||
n += 1;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ use std::sync::{Arc, Mutex};
|
|||
|
||||
impl crate::disk::Xmrig {
|
||||
#[inline(always)] // called once
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn show(
|
||||
&mut self,
|
||||
pool_vec: &mut Vec<(String, Pool)>,
|
||||
|
@ -282,8 +283,7 @@ impl crate::disk::Xmrig {
|
|||
debug!("XMRig Tab | Rendering [Node List] ComboBox");
|
||||
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| {
|
||||
let mut n = 0;
|
||||
for (name, pool) in pool_vec.iter() {
|
||||
for (n, (name, pool)) in pool_vec.iter().enumerate() {
|
||||
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() {
|
||||
self.selected_index = n;
|
||||
|
@ -297,7 +297,6 @@ impl crate::disk::Xmrig {
|
|||
self.ip = pool.ip;
|
||||
self.port = pool.port;
|
||||
}
|
||||
n += 1;
|
||||
}
|
||||
});
|
||||
// [Add/Save]
|
||||
|
|
Loading…
Reference in a new issue