mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-11-16 15:27:46 +00:00
Cargo update + clippy lint fixes
This commit is contained in:
parent
e76e9e91ab
commit
6af2ffcc16
11 changed files with 238 additions and 259 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -2342,7 +2342,7 @@ checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
|
|||
dependencies = [
|
||||
"bitflags",
|
||||
"jni-sys",
|
||||
"ndk-sys 0.4.0",
|
||||
"ndk-sys 0.4.1+23.1.7779620",
|
||||
"num_enum",
|
||||
"raw-window-handle 0.5.0",
|
||||
"thiserror",
|
||||
|
@ -2380,7 +2380,7 @@ dependencies = [
|
|||
"ndk 0.7.0",
|
||||
"ndk-context",
|
||||
"ndk-macro",
|
||||
"ndk-sys 0.4.0",
|
||||
"ndk-sys 0.4.1+23.1.7779620",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
]
|
||||
|
@ -2409,9 +2409,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ndk-sys"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1+23.1.7779620"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046"
|
||||
checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3"
|
||||
dependencies = [
|
||||
"jni-sys",
|
||||
]
|
||||
|
@ -2633,9 +2633,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.42"
|
||||
version = "0.10.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13"
|
||||
checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
|
@ -2674,9 +2674,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.77"
|
||||
version = "0.9.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a"
|
||||
checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
|
@ -5260,9 +5260,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zstd-sys"
|
||||
version = "2.0.1+zstd.1.5.2"
|
||||
version = "2.0.2+zstd.1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
|
||||
checksum = "24faa29d97c8ddca9b37b680e3bd2d5439d864a9cac3a0640d086b71c908bb83"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
|
124
src/constants.rs
124
src/constants.rs
|
@ -15,10 +15,10 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub const GUPAX_VERSION: &'static str = concat!("v", env!("CARGO_PKG_VERSION"));
|
||||
pub const P2POOL_VERSION: &'static str = "v2.4";
|
||||
pub const XMRIG_VERSION: &'static str = "v6.18.0";
|
||||
pub const COMMIT: &'static str = include_str!("../.git/refs/heads/main");
|
||||
pub const GUPAX_VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));
|
||||
pub const P2POOL_VERSION: &str = "v2.4";
|
||||
pub const XMRIG_VERSION: &str = "v6.18.0";
|
||||
pub const COMMIT: &str = include_str!("../.git/refs/heads/main");
|
||||
|
||||
// App frame resolution, [16:10] aspect ratio, height = width * 1.6
|
||||
pub const APP_MIN_WIDTH: f32 = 768.0;
|
||||
|
@ -35,9 +35,9 @@ pub const BYTES_ICON: &[u8] = include_bytes!("../images/icons/icon@2x.png");
|
|||
#[cfg(not(target_os = "macos"))]
|
||||
pub const BYTES_ICON: &[u8] = include_bytes!("../images/icons/icon.png");
|
||||
pub const BYTES_BANNER: &[u8] = include_bytes!("../images/banner.png");
|
||||
pub const P2POOL_BASE_ARGS: &'static str = "";
|
||||
pub const XMRIG_BASE_ARGS: &'static str = "--http-host=127.0.0.1 --http-port=18088 --algo=rx/0 --coin=Monero";
|
||||
pub const HORIZONTAL: &'static str = "--------------------------------------------";
|
||||
pub const P2POOL_BASE_ARGS: &str = "";
|
||||
pub const XMRIG_BASE_ARGS: &str = "--http-host=127.0.0.1 --http-port=18088 --algo=rx/0 --coin=Monero";
|
||||
pub const HORIZONTAL: &str = "--------------------------------------------";
|
||||
|
||||
// This is the typical space added when using
|
||||
// [ui.separator()] or [ui.group()]
|
||||
|
@ -64,81 +64,81 @@ pub const OS: &'static str = " macOS";
|
|||
pub const OS_NAME: &'static str = "macOS";
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const OS: &'static str = "🐧 Linux";
|
||||
pub const OS: &str = "🐧 Linux";
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const OS_NAME: &'static str = "Linux";
|
||||
pub const OS_NAME: &str = "Linux";
|
||||
|
||||
// Tooltips
|
||||
// Gupax
|
||||
pub const GUPAX_UPDATE: &'static str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically";
|
||||
pub const GUPAX_AUTO_UPDATE: &'static str = "Automatically check for updates at startup";
|
||||
pub const GUPAX_UPDATE: &str = "Check for updates on Gupax, P2Pool, and XMRig via GitHub's API and upgrade automatically";
|
||||
pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup";
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub const GUPAX_UPDATE_VIA_TOR: &'static str = "Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
|
||||
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
|
||||
pub const GUPAX_UPDATE_VIA_TOR: &'static str = "WARNING: This option is unstable on macOS. Update through the Tor network. Tor is embedded within Gupax; a Tor system proxy is not required";
|
||||
pub const GUPAX_ASK_BEFORE_QUIT: &'static str = "Ask before quitting Gupax";
|
||||
pub const GUPAX_SAVE_BEFORE_QUIT: &'static str = "Automatically save any changed settings before quitting";
|
||||
pub const GUPAX_WIDTH: &'static str = "Set the width of the Gupax window";
|
||||
pub const GUPAX_HEIGHT: &'static str = "Set the height of the Gupax window";
|
||||
pub const GUPAX_LOCK_WIDTH: &'static str = "Automatically match the height against the width in a 16:10 ratio; aka HEIGHT = WIDTH / 1.6";
|
||||
pub const GUPAX_LOCK_HEIGHT: &'static str = "Automatically match the width against the height in a 16:10 ratio; aka WIDTH = HEIGHT * 1.6";
|
||||
pub const GUPAX_NO_LOCK: &'static str = "Allow individual selection of width and height";
|
||||
pub const GUPAX_SET: &'static str = "Set the width/height of the Gupax window to the current values";
|
||||
pub const GUPAX_SIMPLE: &'static str =
|
||||
pub const GUPAX_ASK_BEFORE_QUIT: &str = "Ask before quitting Gupax";
|
||||
pub const GUPAX_SAVE_BEFORE_QUIT: &str = "Automatically save any changed settings before quitting";
|
||||
pub const GUPAX_WIDTH: &str = "Set the width of the Gupax window";
|
||||
pub const GUPAX_HEIGHT: &str = "Set the height of the Gupax window";
|
||||
pub const GUPAX_LOCK_WIDTH: &str = "Automatically match the height against the width in a 16:10 ratio; aka HEIGHT = WIDTH / 1.6";
|
||||
pub const GUPAX_LOCK_HEIGHT: &str = "Automatically match the width against the height in a 16:10 ratio; aka WIDTH = HEIGHT * 1.6";
|
||||
pub const GUPAX_NO_LOCK: &str = "Allow individual selection of width and height";
|
||||
pub const GUPAX_SET: &str = "Set the width/height of the Gupax window to the current values";
|
||||
pub const GUPAX_SIMPLE: &str =
|
||||
r#"Use simple Gupax settings:
|
||||
- Update button
|
||||
- Basic toggles"#;
|
||||
pub const GUPAX_ADVANCED: &'static str =
|
||||
pub const GUPAX_ADVANCED: &str =
|
||||
r#"Use advanced Gupax settings:
|
||||
- Update button
|
||||
- Basic toggles
|
||||
- P2Pool/XMRig binary path selector
|
||||
- Gupax resolution sliders"#;
|
||||
pub const GUPAX_SELECT: &'static str = "Open a file explorer to select a file";
|
||||
pub const GUPAX_PATH_P2POOL: &'static 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: &'static 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";
|
||||
pub const GUPAX_SELECT: &str = "Open a file explorer to select a file";
|
||||
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";
|
||||
|
||||
// P2Pool
|
||||
pub const P2POOL_MAIN: &'static str = "Use the P2Pool main-chain. This P2Pool finds shares faster, but has a higher difficulty. Suitable for miners with more than 50kH/s";
|
||||
pub const P2POOL_MINI: &'static str = "Use the P2Pool mini-chain. This P2Pool finds shares slower, but has a lower difficulty. Suitable for miners with less than 50kH/s";
|
||||
pub const P2POOL_OUT: &'static str = "How many out-bound peers to connect to? (you connecting to others)";
|
||||
pub const P2POOL_IN: &'static str = "How many in-bound peers to allow? (others connecting to you)";
|
||||
pub const P2POOL_LOG: &'static str = "Verbosity of the console log";
|
||||
pub const P2POOL_AUTO_NODE: &'static str = "Automatically ping the community Monero nodes at Gupax startup";
|
||||
pub const P2POOL_AUTO_SELECT: &'static str = "Automatically select the fastest community Monero node after pinging";
|
||||
pub const P2POOL_SELECT_FASTEST: &'static str = "Select the fastest community Monero node";
|
||||
pub const P2POOL_PING: &'static str = "Ping the built-in community Monero nodes";
|
||||
pub const P2POOL_ADDRESS: &'static str = "You must use a primary Monero address to mine on P2Pool (starts with a 4). It is highly recommended to create a new wallet for P2Pool mining; wallet addresses are public on P2Pool!";
|
||||
pub const P2POOL_COMMAND: &'static str = "Start P2Pool with these arguments and override all below settings; If the [--data-api] flag is not given, Gupax will append it to the arguments automatically so that the [Status] tab can work";
|
||||
pub const P2POOL_SIMPLE: &'static str =
|
||||
pub const P2POOL_MAIN: &str = "Use the P2Pool main-chain. This P2Pool finds shares faster, but has a higher difficulty. Suitable for miners with more than 50kH/s";
|
||||
pub const P2POOL_MINI: &str = "Use the P2Pool mini-chain. This P2Pool finds shares slower, but has a lower difficulty. Suitable for miners with less than 50kH/s";
|
||||
pub const P2POOL_OUT: &str = "How many out-bound peers to connect to? (you connecting to others)";
|
||||
pub const P2POOL_IN: &str = "How many in-bound peers to allow? (others connecting to you)";
|
||||
pub const P2POOL_LOG: &str = "Verbosity of the console log";
|
||||
pub const P2POOL_AUTO_NODE: &str = "Automatically ping the community Monero nodes at Gupax startup";
|
||||
pub const P2POOL_AUTO_SELECT: &str = "Automatically select the fastest community Monero node after pinging";
|
||||
pub const P2POOL_SELECT_FASTEST: &str = "Select the fastest community Monero node";
|
||||
pub const P2POOL_PING: &str = "Ping the built-in community Monero nodes";
|
||||
pub const P2POOL_ADDRESS: &str = "You must use a primary Monero address to mine on P2Pool (starts with a 4). It is highly recommended to create a new wallet for P2Pool mining; wallet addresses are public on P2Pool!";
|
||||
pub const P2POOL_COMMAND: &str = "Start P2Pool with these arguments and override all below settings; If the [--data-api] flag is not given, Gupax will append it to the arguments automatically so that the [Status] tab can work";
|
||||
pub const P2POOL_SIMPLE: &str =
|
||||
r#"Use simple P2Pool settings:
|
||||
- Remote community Monero node
|
||||
- Default P2Pool settings + Mini"#;
|
||||
pub const P2POOL_ADVANCED: &'static str =
|
||||
pub const P2POOL_ADVANCED: &str =
|
||||
r#"Use advanced P2Pool settings:
|
||||
- Overriding command arguments
|
||||
- Manual node list
|
||||
- P2Pool Main/Mini selection
|
||||
- Out/In peer setting
|
||||
- Log level setting"#;
|
||||
pub const P2POOL_NAME: &'static str = "Add a unique name to identify this node; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const P2POOL_NODE_IP: &'static str = "Specify the Monero Node IP to connect to with P2Pool; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
|
||||
pub const P2POOL_RPC_PORT: &'static str = "Specify the RPC port of the Monero node; [1-65535]";
|
||||
pub const P2POOL_ZMQ_PORT: &'static str = "Specify the ZMQ port of the Monero node; [1-65535]";
|
||||
pub const P2POOL_NAME: &str = "Add a unique name to identify this node; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const P2POOL_NODE_IP: &str = "Specify the Monero Node IP to connect to with P2Pool; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
|
||||
pub const P2POOL_RPC_PORT: &str = "Specify the RPC port of the Monero node; [1-65535]";
|
||||
pub const P2POOL_ZMQ_PORT: &str = "Specify the ZMQ port of the Monero node; [1-65535]";
|
||||
|
||||
// Node/Pool list
|
||||
pub const LIST_ADD: &'static str = "Add the current values to the list";
|
||||
pub const LIST_SAVE: &'static str = "Save the current values to the already existing entry";
|
||||
pub const LIST_DELETE: &'static str = "Delete the currently selected entry";
|
||||
pub const LIST_CLEAR: &'static str = "Clear all current values";
|
||||
pub const LIST_ADD: &str = "Add the current values to the list";
|
||||
pub const LIST_SAVE: &str = "Save the current values to the already existing entry";
|
||||
pub const LIST_DELETE: &str = "Delete the currently selected entry";
|
||||
pub const LIST_CLEAR: &str = "Clear all current values";
|
||||
|
||||
// XMRig
|
||||
pub const XMRIG_SIMPLE: &'static str =
|
||||
pub const XMRIG_SIMPLE: &str =
|
||||
r#"Use simple XMRig settings:
|
||||
- Mine to local P2Pool (localhost:3333)
|
||||
- CPU thread slider
|
||||
- HTTP API @ localhost:18088"#;
|
||||
pub const XMRIG_ADVANCED: &'static str =
|
||||
pub const XMRIG_ADVANCED: &str =
|
||||
r#"Use advanced XMRig settings:
|
||||
- Overriding config file
|
||||
- Custom payout address
|
||||
|
@ -147,21 +147,21 @@ r#"Use advanced XMRig settings:
|
|||
- TLS setting
|
||||
- Keepalive setting
|
||||
- Custom HTTP API IP/Port"#;
|
||||
pub const XMRIG_CONFIG: &'static str = "Start XMRig with this config file and override all below settings; If the [http-api] options are not set, the [Status] tab will not properly show XMRig stats. If they are set, Gupax will detect which automatically IP/Port you are using";
|
||||
pub const XMRIG_ADDRESS: &'static str = "Specify which Monero address to send payouts to; Must be a valid primary address (starts with 4)";
|
||||
pub const XMRIG_NAME: &'static str = "Add a unique name to identify this pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const XMRIG_IP: &'static str = "Specify the pool IP to connect to with XMRig; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
|
||||
pub const XMRIG_PORT: &'static str = "Specify the port of the pool; [1-65535]";
|
||||
pub const XMRIG_RIG: &'static str = "Add a unique rig ID. This will be the name shown on the pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const XMRIG_PAUSE: &'static str = "THIS SETTING IS DISABLED IF SET TO [0]. Pause mining if user is active, resume after";
|
||||
pub const XMRIG_API_IP: &'static str = "Specify which IP to bind to for XMRig's HTTP API";
|
||||
pub const XMRIG_API_PORT: &'static str = "Specify which port to bind to for XMRig's HTTP API";
|
||||
pub const XMRIG_TLS: &'static str = "Enable SSL/TLS connections (needs pool support)";
|
||||
pub const XMRIG_KEEPALIVE: &'static str = "Send keepalived packet to prevent timeout (needs pool support)";
|
||||
pub const XMRIG_THREADS: &'static str = "Number of CPU threads to use for mining";
|
||||
pub const XMRIG_CONFIG: &str = "Start XMRig with this config file and override all below settings; If the [http-api] options are not set, the [Status] tab will not properly show XMRig stats. If they are set, Gupax will detect which automatically IP/Port you are using";
|
||||
pub const XMRIG_ADDRESS: &str = "Specify which Monero address to send payouts to; Must be a valid primary address (starts with 4)";
|
||||
pub const XMRIG_NAME: &str = "Add a unique name to identify this pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const XMRIG_IP: &str = "Specify the pool IP to connect to with XMRig; It must be a valid IPv4 address or a valid domain name; Max length = 255 characters";
|
||||
pub const XMRIG_PORT: &str = "Specify the port of the pool; [1-65535]";
|
||||
pub const XMRIG_RIG: &str = "Add a unique rig ID. This will be the name shown on the pool; Only [A-Za-z0-9-_] and spaces allowed; Max length = 30 characters";
|
||||
pub const XMRIG_PAUSE: &str = "THIS SETTING IS DISABLED IF SET TO [0]. Pause mining if user is active, resume after";
|
||||
pub const XMRIG_API_IP: &str = "Specify which IP to bind to for XMRig's HTTP API";
|
||||
pub const XMRIG_API_PORT: &str = "Specify which port to bind to for XMRig's HTTP API";
|
||||
pub const XMRIG_TLS: &str = "Enable SSL/TLS connections (needs pool support)";
|
||||
pub const XMRIG_KEEPALIVE: &str = "Send keepalived packet to prevent timeout (needs pool support)";
|
||||
pub const XMRIG_THREADS: &str = "Number of CPU threads to use for mining";
|
||||
|
||||
// CLI argument messages
|
||||
pub const ARG_HELP: &'static str =
|
||||
pub const ARG_HELP: &str =
|
||||
r#"USAGE: ./gupax [--flag]
|
||||
|
||||
--help Print this help message
|
||||
|
@ -178,7 +178,7 @@ r#"USAGE: ./gupax [--flag]
|
|||
To view more detailed console debug information, start Gupax with
|
||||
the environment variable [RUST_LOG] set to a log level like so:
|
||||
RUST_LOG=(trace|debug|info|warn|error) ./gupax"#;
|
||||
pub const ARG_COPYRIGHT: &'static str =
|
||||
pub const ARG_COPYRIGHT: &str =
|
||||
r#"Gupax is licensed under GPLv3.
|
||||
For more information, see link below:
|
||||
<https://github.com/hinto-janaiyo/gupax>"#;
|
||||
|
|
77
src/disk.rs
77
src/disk.rs
|
@ -49,23 +49,23 @@ use log::*;
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- Const
|
||||
// State file
|
||||
const ERROR: &'static str = "Disk error";
|
||||
const PATH_ERROR: &'static str = "PATH for state directory could not be not found";
|
||||
const ERROR: &str = "Disk error";
|
||||
const PATH_ERROR: &str = "PATH for state directory could not be not found";
|
||||
#[cfg(target_os = "windows")]
|
||||
const DIRECTORY: &'static str = r#"Gupax\"#;
|
||||
#[cfg(target_os = "macos")]
|
||||
const DIRECTORY: &'static str = "Gupax/";
|
||||
#[cfg(target_os = "linux")]
|
||||
const DIRECTORY: &'static str = "gupax/";
|
||||
const DIRECTORY: &str = "gupax/";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub const DEFAULT_P2POOL_PATH: &'static str = r"P2Pool\p2pool.exe";
|
||||
#[cfg(target_family = "unix")]
|
||||
pub const DEFAULT_P2POOL_PATH: &'static str = "p2pool/p2pool";
|
||||
pub const DEFAULT_P2POOL_PATH: &str = "p2pool/p2pool";
|
||||
#[cfg(target_os = "windows")]
|
||||
pub const DEFAULT_XMRIG_PATH: &'static str = r"XMRig\xmrig.exe";
|
||||
#[cfg(target_family = "unix")]
|
||||
pub const DEFAULT_XMRIG_PATH: &'static str = "xmrig/xmrig";
|
||||
pub const DEFAULT_XMRIG_PATH: &str = "xmrig/xmrig";
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- General functions for all [File]'s
|
||||
// get_file_path() | Return absolute path to OS data path + filename
|
||||
|
@ -99,7 +99,7 @@ pub fn create_gupax_dir(path: &PathBuf) -> Result<(), TomlError> {
|
|||
|
||||
// Convert a [File] path to a [String]
|
||||
pub fn read_to_string(file: File, path: &PathBuf) -> Result<String, TomlError> {
|
||||
match fs::read_to_string(&path) {
|
||||
match fs::read_to_string(path) {
|
||||
Ok(string) => {
|
||||
info!("{:?} | Read ... OK", file);
|
||||
Ok(string)
|
||||
|
@ -111,8 +111,8 @@ pub fn read_to_string(file: File, path: &PathBuf) -> Result<String, TomlError> {
|
|||
}
|
||||
}
|
||||
|
||||
// Write [String] to console with [info!] surrounded by "---"
|
||||
pub fn print_toml(toml: &String) {
|
||||
// Write str to console with [info!] surrounded by "---"
|
||||
pub fn print_toml(toml: &str) {
|
||||
info!("{}", HORIZONTAL);
|
||||
for i in toml.lines() { info!("{}", i); }
|
||||
info!("{}", HORIZONTAL);
|
||||
|
@ -135,8 +135,7 @@ pub fn into_absolute_path(path: String) -> Result<PathBuf, TomlError> {
|
|||
impl State {
|
||||
pub fn new() -> Self {
|
||||
let max_threads = num_cpus::get();
|
||||
let current_threads;
|
||||
if max_threads == 1 { current_threads = 1; } else { current_threads = max_threads / 2; }
|
||||
let current_threads = if max_threads == 1 { 1 } else { max_threads / 2 };
|
||||
Self {
|
||||
gupax: Gupax {
|
||||
simple: true,
|
||||
|
@ -206,12 +205,12 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
// Convert [String] to [State]
|
||||
pub fn from_string(string: &String) -> Result<Self, TomlError> {
|
||||
match toml::de::from_str(&string) {
|
||||
// Convert [&str] to [State]
|
||||
pub fn from_str(string: &str) -> Result<Self, TomlError> {
|
||||
match toml::de::from_str(string) {
|
||||
Ok(state) => {
|
||||
info!("State | Parse ... OK");
|
||||
print_toml(&string);
|
||||
print_toml(string);
|
||||
Ok(state)
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -229,19 +228,19 @@ impl State {
|
|||
pub fn get(path: &PathBuf) -> Result<Self, TomlError> {
|
||||
// Read
|
||||
let file = File::State;
|
||||
let string = match read_to_string(file, &path) {
|
||||
let string = match read_to_string(file, path) {
|
||||
Ok(string) => string,
|
||||
// Create
|
||||
_ => {
|
||||
Self::create_new(path)?;
|
||||
match read_to_string(file, &path) {
|
||||
match read_to_string(file, path) {
|
||||
Ok(s) => s,
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
},
|
||||
};
|
||||
// Deserialize, attempt merge if failed
|
||||
match Self::from_string(&string) {
|
||||
match Self::from_str(&string) {
|
||||
Ok(s) => Ok(s),
|
||||
Err(_) => {
|
||||
warn!("State | Attempting merge...");
|
||||
|
@ -259,7 +258,7 @@ impl State {
|
|||
Ok(o) => o,
|
||||
Err(e) => { error!("State | Couldn't serialize default file: {}", e); return Err(TomlError::Serialize(e)) },
|
||||
};
|
||||
fs::write(&path, &string)?;
|
||||
fs::write(path, &string)?;
|
||||
info!("State | Write ... OK");
|
||||
Ok(new)
|
||||
}
|
||||
|
@ -280,7 +279,7 @@ impl State {
|
|||
};
|
||||
match fs::write(path, string) {
|
||||
Ok(_) => { info!("State | Save ... OK"); Ok(()) },
|
||||
Err(err) => { error!("State | Couldn't overwrite TOML file ... FAIL"); return Err(TomlError::Io(err)) },
|
||||
Err(err) => { error!("State | Couldn't overwrite TOML file ... FAIL"); Err(TomlError::Io(err)) },
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,14 +312,12 @@ impl Node {
|
|||
}
|
||||
|
||||
pub fn new_vec() -> Vec<(String, Self)> {
|
||||
let mut vec = Vec::new();
|
||||
vec.push(("Local Monero Node".to_string(), Self::localhost()));
|
||||
vec
|
||||
vec![("Local Monero Node".to_string(), Self::localhost())]
|
||||
}
|
||||
|
||||
// Convert [String] to [Node] Vec
|
||||
pub fn from_string_to_vec(string: &String) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
let nodes: toml::map::Map<String, toml::Value> = match toml::de::from_str(&string) {
|
||||
pub fn from_str_to_vec(string: &str) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
let nodes: toml::map::Map<String, toml::Value> = match toml::de::from_str(string) {
|
||||
Ok(map) => {
|
||||
info!("Node | Parse ... OK");
|
||||
map
|
||||
|
@ -345,7 +342,7 @@ impl Node {
|
|||
|
||||
// Convert [Vec<(String, Self)>] into [String]
|
||||
// that can be written as a proper TOML file
|
||||
pub fn to_string(vec: &Vec<(String, Self)>) -> Result<String, TomlError> {
|
||||
pub fn to_string(vec: &[(String, Self)]) -> Result<String, TomlError> {
|
||||
let mut toml = String::new();
|
||||
for (key, value) in vec.iter() {
|
||||
write!(
|
||||
|
@ -368,16 +365,16 @@ impl Node {
|
|||
pub fn get(path: &PathBuf) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
// Read
|
||||
let file = File::Node;
|
||||
let string = match read_to_string(file, &path) {
|
||||
let string = match read_to_string(file, path) {
|
||||
Ok(string) => string,
|
||||
// Create
|
||||
_ => {
|
||||
Self::create_new(path)?;
|
||||
read_to_string(file, &path)?
|
||||
read_to_string(file, path)?
|
||||
},
|
||||
};
|
||||
// Deserialize, attempt merge if failed
|
||||
Self::from_string_to_vec(&string)
|
||||
Self::from_str_to_vec(&string)
|
||||
}
|
||||
|
||||
// Completely overwrite current [node.toml]
|
||||
|
@ -386,13 +383,13 @@ impl Node {
|
|||
info!("Node | Creating new default...");
|
||||
let new = Self::new_vec();
|
||||
let string = Self::to_string(&Self::new_vec())?;
|
||||
fs::write(&path, &string)?;
|
||||
fs::write(path, &string)?;
|
||||
info!("Node | Write ... OK");
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
// Save [Node] onto disk file [node.toml]
|
||||
pub fn save(vec: &Vec<(String, Self)>, path: &PathBuf) -> Result<(), TomlError> {
|
||||
pub fn save(vec: &[(String, Self)], path: &PathBuf) -> Result<(), TomlError> {
|
||||
info!("Node | Saving to disk...");
|
||||
let string = Self::to_string(vec)?;
|
||||
match fs::write(path, string) {
|
||||
|
@ -428,13 +425,11 @@ impl Pool {
|
|||
}
|
||||
|
||||
pub fn new_vec() -> Vec<(String, Self)> {
|
||||
let mut vec = Vec::new();
|
||||
vec.push(("Local P2Pool".to_string(), Self::p2pool()));
|
||||
vec
|
||||
vec![("Local P2Pool".to_string(), Self::p2pool())]
|
||||
}
|
||||
|
||||
pub fn from_string_to_vec(string: &String) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
let pools: toml::map::Map<String, toml::Value> = match toml::de::from_str(&string) {
|
||||
pub fn from_str_to_vec(string: &str) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
let pools: toml::map::Map<String, toml::Value> = match toml::de::from_str(string) {
|
||||
Ok(map) => {
|
||||
info!("Pool | Parse ... OK");
|
||||
map
|
||||
|
@ -457,7 +452,7 @@ impl Pool {
|
|||
Ok(vec)
|
||||
}
|
||||
|
||||
pub fn to_string(vec: &Vec<(String, Self)>) -> Result<String, TomlError> {
|
||||
pub fn to_string(vec: &[(String, Self)]) -> Result<String, TomlError> {
|
||||
let mut toml = String::new();
|
||||
for (key, value) in vec.iter() {
|
||||
write!(
|
||||
|
@ -475,28 +470,28 @@ impl Pool {
|
|||
pub fn get(path: &PathBuf) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
// Read
|
||||
let file = File::Pool;
|
||||
let string = match read_to_string(file, &path) {
|
||||
let string = match read_to_string(file, path) {
|
||||
Ok(string) => string,
|
||||
// Create
|
||||
_ => {
|
||||
Self::create_new(path)?;
|
||||
read_to_string(file, &path)?
|
||||
read_to_string(file, path)?
|
||||
},
|
||||
};
|
||||
// Deserialize
|
||||
Self::from_string_to_vec(&string)
|
||||
Self::from_str_to_vec(&string)
|
||||
}
|
||||
|
||||
pub fn create_new(path: &PathBuf) -> Result<Vec<(String, Self)>, TomlError> {
|
||||
info!("Pool | Creating new default...");
|
||||
let new = Self::new_vec();
|
||||
let string = Self::to_string(&Self::new_vec())?;
|
||||
fs::write(&path, &string)?;
|
||||
fs::write(path, &string)?;
|
||||
info!("Pool | Write ... OK");
|
||||
Ok(new)
|
||||
}
|
||||
|
||||
pub fn save(vec: &Vec<(String, Self)>, path: &PathBuf) -> Result<(), TomlError> {
|
||||
pub fn save(vec: &[(String, Self)], path: &PathBuf) -> Result<(), TomlError> {
|
||||
info!("Pool | Saving to disk...");
|
||||
let string = Self::to_string(vec)?;
|
||||
match fs::write(path, string) {
|
||||
|
|
File diff suppressed because one or more lines are too long
14
src/gupax.rs
14
src/gupax.rs
|
@ -20,7 +20,7 @@ use egui::{
|
|||
TextStyle::Monospace,
|
||||
Checkbox,ProgressBar,Spinner,Button,Label,Slider,
|
||||
SelectableLabel,
|
||||
RichText,Color32,
|
||||
RichText,
|
||||
Vec2,
|
||||
};
|
||||
use crate::constants::*;
|
||||
|
@ -29,7 +29,7 @@ use crate::update::*;
|
|||
use std::{
|
||||
thread,
|
||||
sync::{Arc,Mutex},
|
||||
path::PathBuf,
|
||||
path::Path,
|
||||
};
|
||||
use log::*;
|
||||
use serde::{Serialize,Deserialize};
|
||||
|
@ -75,7 +75,7 @@ pub enum Ratio {
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- Gupax
|
||||
impl Gupax {
|
||||
pub fn show(&mut self, og: &Arc<Mutex<State>>, state_ver: &Arc<Mutex<Version>>, update: &Arc<Mutex<Update>>, file_window: &Arc<Mutex<FileWindow>>, state_path: &PathBuf, width: f32, height: f32, frame: &mut eframe::Frame, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
pub fn show(&mut self, og: &Arc<Mutex<State>>, state_ver: &Arc<Mutex<Version>>, update: &Arc<Mutex<Update>>, file_window: &Arc<Mutex<FileWindow>>, state_path: &Path, width: f32, height: f32, frame: &mut eframe::Frame, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
// Update button + Progress bar
|
||||
ui.group(|ui| {
|
||||
// These are in unnecessary [ui.vertical()]'s
|
||||
|
@ -150,7 +150,7 @@ impl Gupax {
|
|||
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
|
||||
ui.set_enabled(!file_window.lock().unwrap().thread);
|
||||
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
||||
Self::spawn_file_window_thread(&file_window, FileType::P2pool);
|
||||
Self::spawn_file_window_thread(file_window, FileType::P2pool);
|
||||
}
|
||||
ui.text_edit_singleline(&mut self.p2pool_path).on_hover_text(GUPAX_PATH_P2POOL);
|
||||
});
|
||||
|
@ -172,7 +172,7 @@ impl Gupax {
|
|||
ui.spacing_mut().text_edit_width = ui.available_width() - SPACE;
|
||||
ui.set_enabled(!file_window.lock().unwrap().thread);
|
||||
if ui.button("Open").on_hover_text(GUPAX_SELECT).clicked() {
|
||||
Self::spawn_file_window_thread(&file_window, FileType::Xmrig);
|
||||
Self::spawn_file_window_thread(file_window, FileType::Xmrig);
|
||||
}
|
||||
ui.text_edit_singleline(&mut self.xmrig_path).on_hover_text(GUPAX_PATH_XMRIG);
|
||||
});
|
||||
|
@ -190,12 +190,12 @@ impl Gupax {
|
|||
Ratio::None => (),
|
||||
Ratio::Width => {
|
||||
let width = self.selected_width as f64;
|
||||
let height = self.selected_height as f64;
|
||||
let _height = self.selected_height as f64;
|
||||
let height = (width / 1.6).round();
|
||||
self.selected_height = height as u16;
|
||||
},
|
||||
Ratio::Height => {
|
||||
let width = self.selected_width as f64;
|
||||
let _width = self.selected_width as f64;
|
||||
let height = self.selected_height as f64;
|
||||
let width = (height * 1.6).round();
|
||||
self.selected_width = width as u16;
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -27,7 +27,6 @@ use egui::{
|
|||
TextStyle,
|
||||
Layout,Align,
|
||||
FontId,Label,RichText,Stroke,Vec2,Button,SelectableLabel,
|
||||
special_emojis::GITHUB,
|
||||
Key,Modifiers,
|
||||
CentralPanel,TopBottomPanel,
|
||||
};
|
||||
|
@ -307,7 +306,7 @@ impl Default for Tab {
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- [ErrorState] struct
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum ErrorButtons {
|
||||
YesNo,
|
||||
StayQuit,
|
||||
|
@ -317,7 +316,7 @@ pub enum ErrorButtons {
|
|||
Quit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum ErrorFerris {
|
||||
Happy,
|
||||
Oops,
|
||||
|
@ -441,14 +440,13 @@ fn init_text_styles(ctx: &egui::Context, width: f32) {
|
|||
fn init_logger(now: Instant) {
|
||||
use env_logger::fmt::Color;
|
||||
Builder::new().format(move |buf, record| {
|
||||
let level;
|
||||
let mut style = buf.style();
|
||||
match record.level() {
|
||||
Level::Error => { style.set_color(Color::Red); level = "ERROR" },
|
||||
Level::Warn => { style.set_color(Color::Yellow); level = "WARN" },
|
||||
Level::Info => { style.set_color(Color::White); level = "INFO" },
|
||||
Level::Debug => { style.set_color(Color::Blue); level = "DEBUG" },
|
||||
Level::Trace => { style.set_color(Color::Magenta); level = "TRACE" },
|
||||
let level = match record.level() {
|
||||
Level::Error => { style.set_color(Color::Red); "ERROR" },
|
||||
Level::Warn => { style.set_color(Color::Yellow); "WARN" },
|
||||
Level::Info => { style.set_color(Color::White); "INFO" },
|
||||
Level::Debug => { style.set_color(Color::Blue); "DEBUG" },
|
||||
Level::Trace => { style.set_color(Color::Magenta); "TRACE" },
|
||||
};
|
||||
writeln!(
|
||||
buf,
|
||||
|
@ -594,7 +592,7 @@ fn parse_args<S: Into<String>>(mut app: App, panic: S) -> App {
|
|||
pub fn get_exe() -> Result<String, std::io::Error> {
|
||||
match std::env::current_exe() {
|
||||
Ok(path) => { Ok(path.display().to_string()) },
|
||||
Err(err) => { error!("Couldn't get absolute Gupax PATH"); return Err(err) },
|
||||
Err(err) => { error!("Couldn't get absolute Gupax PATH"); Err(err) },
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,7 +600,7 @@ pub fn get_exe() -> Result<String, std::io::Error> {
|
|||
pub fn get_exe_dir() -> Result<String, std::io::Error> {
|
||||
match std::env::current_exe() {
|
||||
Ok(mut path) => { path.pop(); Ok(path.display().to_string()) },
|
||||
Err(err) => { error!("Couldn't get exe basepath PATH"); return Err(err) },
|
||||
Err(err) => { error!("Couldn't get exe basepath PATH"); Err(err) },
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,7 +611,7 @@ pub fn clean_dir() -> Result<(), anyhow::Error> {
|
|||
for entry in std::fs::read_dir(get_exe_dir()?)? {
|
||||
let entry = entry?;
|
||||
if ! entry.path().is_dir() { continue }
|
||||
if Regex::is_match(®ex, entry.file_name().to_str().ok_or(anyhow::Error::msg("Basename failed"))?) {
|
||||
if Regex::is_match(®ex, entry.file_name().to_str().ok_or_else(|| anyhow::Error::msg("Basename failed"))?) {
|
||||
let path = entry.path();
|
||||
match std::fs::remove_dir_all(&path) {
|
||||
Ok(_) => info!("Remove [{}] ... OK", path.display()),
|
||||
|
@ -626,7 +624,7 @@ pub fn clean_dir() -> Result<(), anyhow::Error> {
|
|||
|
||||
// Print disk files to console
|
||||
fn print_disk_file(path: &PathBuf) {
|
||||
match std::fs::read_to_string(&path) {
|
||||
match std::fs::read_to_string(path) {
|
||||
Ok(string) => { print!("{}", string); exit(0); },
|
||||
Err(e) => { error!("{}", e); exit(1); },
|
||||
}
|
||||
|
@ -994,7 +992,7 @@ impl eframe::App for App {
|
|||
|
||||
ui.add_space(ui.available_height()/1.8);
|
||||
ui.hyperlink_to("Powered by egui", "https://github.com/emilk/egui");
|
||||
ui.hyperlink_to(format!("{}", "Made by hinto-janaiyo"), "https://gupax.io");
|
||||
ui.hyperlink_to("Made by hinto-janaiyo".to_string(), "https://gupax.io");
|
||||
ui.label("egui is licensed under MIT & Apache-2.0");
|
||||
ui.label("Gupax, P2Pool, and XMRig are licensed under GPLv3");
|
||||
});
|
||||
|
|
44
src/node.rs
44
src/node.rs
|
@ -34,26 +34,26 @@ use hyper::{
|
|||
// Adding/removing nodes will need changes to pretty
|
||||
// much all the code in this file, and the code that
|
||||
// handles the actual Enum selector in the P2Pool tab.
|
||||
pub const C3POOL: &'static str = "node.c3pool.com:18081";
|
||||
pub const CAKE: &'static str = "xmr-node.cakewallet.com:18081";
|
||||
pub const CAKE_EU: &'static str = "xmr-node-eu.cakewallet.com:18081";
|
||||
pub const CAKE_UK: &'static str = "xmr-node-uk.cakewallet.com:18081";
|
||||
pub const CAKE_US: &'static str = "xmr-node-usa-east.cakewallet.com:18081";
|
||||
pub const FEATHER_1: &'static str = "selsta1.featherwallet.net:18081";
|
||||
pub const FEATHER_2: &'static str = "selsta2.featherwallet.net:18081";
|
||||
pub const MAJESTICBANK_IS: &'static str = "node.majesticbank.is:18089";
|
||||
pub const MAJESTICBANK_SU: &'static str = "node.majesticbank.su:18089";
|
||||
pub const MONERUJO: &'static str = "nodex.monerujo.io:18081";
|
||||
pub const PLOWSOF_1: &'static str = "node.monerodevs.org:18089"; // ZMQ = 18084
|
||||
pub const PLOWSOF_2: &'static str = "node2.monerodevs.org:18089"; // ZMQ = 18084
|
||||
pub const RINO: &'static str = "node.community.rino.io:18081";
|
||||
pub const SETH: &'static str = "node.sethforprivacy.com:18089";
|
||||
pub const SUPPORTXMR: &'static str = "node.supportxmr.com:18081";
|
||||
pub const SUPPORTXMR_IR: &'static str = "node.supportxmr.ir:18081";
|
||||
pub const SINGAPORE: &'static str = "singapore.node.xmr.pm:18089";
|
||||
pub const XMRVSBEAST: &'static str = "p2pmd.xmrvsbeast.com:18081";
|
||||
pub const C3POOL: &str = "node.c3pool.com:18081";
|
||||
pub const CAKE: &str = "xmr-node.cakewallet.com:18081";
|
||||
pub const CAKE_EU: &str = "xmr-node-eu.cakewallet.com:18081";
|
||||
pub const CAKE_UK: &str = "xmr-node-uk.cakewallet.com:18081";
|
||||
pub const CAKE_US: &str = "xmr-node-usa-east.cakewallet.com:18081";
|
||||
pub const FEATHER_1: &str = "selsta1.featherwallet.net:18081";
|
||||
pub const FEATHER_2: &str = "selsta2.featherwallet.net:18081";
|
||||
pub const MAJESTICBANK_IS: &str = "node.majesticbank.is:18089";
|
||||
pub const MAJESTICBANK_SU: &str = "node.majesticbank.su:18089";
|
||||
pub const MONERUJO: &str = "nodex.monerujo.io:18081";
|
||||
pub const PLOWSOF_1: &str = "node.monerodevs.org:18089"; // ZMQ = 18084
|
||||
pub const PLOWSOF_2: &str = "node2.monerodevs.org:18089"; // ZMQ = 18084
|
||||
pub const RINO: &str = "node.community.rino.io:18081";
|
||||
pub const SETH: &str = "node.sethforprivacy.com:18089";
|
||||
pub const SUPPORTXMR: &str = "node.supportxmr.com:18081";
|
||||
pub const SUPPORTXMR_IR: &str = "node.supportxmr.ir:18081";
|
||||
pub const SINGAPORE: &str = "singapore.node.xmr.pm:18089";
|
||||
pub const XMRVSBEAST: &str = "p2pmd.xmrvsbeast.com:18081";
|
||||
|
||||
pub const NODE_IPS: [&'static str; 18] = [
|
||||
pub const NODE_IPS: [&str; 18] = [
|
||||
C3POOL,CAKE,CAKE_EU,CAKE_UK,CAKE_US,FEATHER_1,FEATHER_2,MAJESTICBANK_IS,MAJESTICBANK_SU,
|
||||
MONERUJO,PLOWSOF_1,PLOWSOF_2,RINO,SETH,SUPPORTXMR,SUPPORTXMR_IR,SINGAPORE,XMRVSBEAST,
|
||||
];
|
||||
|
@ -201,7 +201,7 @@ impl Ping {
|
|||
//---------------------------------------------------------------------------------------------------- Main Ping function
|
||||
// Intermediate function for spawning thread
|
||||
pub fn spawn_thread(ping: &Arc<Mutex<Self>>, og: &Arc<Mutex<State>>) {
|
||||
let ping = Arc::clone(&ping);
|
||||
let ping = Arc::clone(ping);
|
||||
let og = Arc::clone(og);
|
||||
std::thread::spawn(move|| {
|
||||
info!("Spawning ping thread...");
|
||||
|
@ -239,7 +239,7 @@ impl Ping {
|
|||
// timeout = BLACK
|
||||
// default = GRAY
|
||||
#[tokio::main]
|
||||
pub async fn ping(ping: Arc<Mutex<Self>>, og: Arc<Mutex<State>>) -> Result<(), anyhow::Error> {
|
||||
pub async fn ping(ping: Arc<Mutex<Self>>, _og: Arc<Mutex<State>>) -> Result<(), anyhow::Error> {
|
||||
// Timer
|
||||
let now = Instant::now();
|
||||
|
||||
|
@ -249,7 +249,7 @@ impl Ping {
|
|||
let percent = (100.0 / ((NODE_IPS.len()) as f32)).floor();
|
||||
|
||||
// Create HTTP client
|
||||
let info = format!("{}", "Creating HTTP Client");
|
||||
let info = "Creating HTTP Client".to_string();
|
||||
ping.lock().unwrap().msg = info;
|
||||
let client: Client<HttpConnector> = Client::builder()
|
||||
.build(HttpConnector::new());
|
||||
|
|
|
@ -31,7 +31,7 @@ use regex::Regex;
|
|||
use log::*;
|
||||
|
||||
impl P2pool {
|
||||
pub fn show(&mut self, node_vec: &mut Vec<(String, Node)>, og: &Arc<Mutex<State>>, online: bool, ping: &Arc<Mutex<Ping>>, regex: &Regexes, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
pub fn show(&mut self, node_vec: &mut Vec<(String, Node)>, og: &Arc<Mutex<State>>, _online: bool, ping: &Arc<Mutex<Ping>>, regex: &Regexes, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
let text_edit = height / 22.0;
|
||||
//---------------------------------------------------------------------------------------------------- Console
|
||||
ui.group(|ui| {
|
||||
|
@ -43,7 +43,7 @@ impl P2pool {
|
|||
});
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Args
|
||||
if self.simple == false {
|
||||
if !self.simple {
|
||||
ui.group(|ui| { ui.horizontal(|ui| {
|
||||
let width = (width/10.0) - SPACE;
|
||||
ui.style_mut().override_text_style = Some(Monospace);
|
||||
|
@ -65,7 +65,7 @@ impl P2pool {
|
|||
if self.address.is_empty() {
|
||||
text = format!("Monero Address [{}/95] ➖", len);
|
||||
color = Color32::LIGHT_GRAY;
|
||||
} else if self.address.len() == 95 && Regex::is_match(®ex.address, &self.address) && ! self.address.contains("0") && ! self.address.contains("O") && ! self.address.contains("l") {
|
||||
} else if self.address.len() == 95 && Regex::is_match(®ex.address, &self.address) && ! self.address.contains('0') && ! self.address.contains('O') && ! self.address.contains('l') {
|
||||
text = format!("Monero Address [{}/95] ✔", len);
|
||||
color = Color32::from_rgb(100, 230, 100);
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ impl P2pool {
|
|||
if self.auto_select {
|
||||
let mut ping = ping.lock().unwrap();
|
||||
// If we haven't auto_selected yet, auto-select and turn it off
|
||||
if ping.pinged && ping.auto_selected == false {
|
||||
if ping.pinged && !ping.auto_selected {
|
||||
self.node = ping.fastest;
|
||||
ping.auto_selected = true;
|
||||
}
|
||||
|
@ -132,16 +132,14 @@ impl P2pool {
|
|||
ui.horizontal(|ui| {
|
||||
let width = (width/2.0)-4.0;
|
||||
// [Select fastest node]
|
||||
if ui.add_sized([width, height], Button::new("Select fastest node")).on_hover_text(P2POOL_SELECT_FASTEST).clicked() {
|
||||
if ping.lock().unwrap().pinged {
|
||||
self.node = ping.lock().unwrap().fastest;
|
||||
}
|
||||
}
|
||||
if ui.add_sized([width, height], Button::new("Select fastest node")).on_hover_text(P2POOL_SELECT_FASTEST).clicked() && ping.lock().unwrap().pinged {
|
||||
self.node = ping.lock().unwrap().fastest;
|
||||
}
|
||||
|
||||
// [Ping Button]
|
||||
ui.set_enabled(!ping.lock().unwrap().pinging);
|
||||
if ui.add_sized([width, height], Button::new("Ping community nodes")).on_hover_text(P2POOL_PING).clicked() {
|
||||
Ping::spawn_thread(&ping, &og);
|
||||
Ping::spawn_thread(ping, og);
|
||||
}});
|
||||
|
||||
ui.vertical(|ui| {
|
||||
|
@ -313,8 +311,7 @@ impl P2pool {
|
|||
existing_index += 1;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let text;
|
||||
if exists { text = LIST_SAVE } else { text = LIST_ADD }
|
||||
let text = if exists { LIST_SAVE } else { LIST_ADD };
|
||||
let text = format!("{}\n Currently selected node: {}. {}\n Current amount of nodes: {}/1000", text, self.selected_index+1, self.selected_name, node_vec_len);
|
||||
// If the node already exists, show [Save] and mutate the already existing node
|
||||
if exists {
|
||||
|
@ -362,7 +359,7 @@ impl P2pool {
|
|||
}
|
||||
_ => {
|
||||
node_vec.remove(self.selected_index);
|
||||
self.selected_index = self.selected_index-1;
|
||||
self.selected_index -= 1;
|
||||
new_name = node_vec[self.selected_index].0.clone();
|
||||
new_node = node_vec[self.selected_index].1.clone();
|
||||
}
|
||||
|
@ -398,8 +395,8 @@ impl P2pool {
|
|||
ui.group(|ui| { ui.horizontal(|ui| {
|
||||
let width = (width/4.0)-SPACE;
|
||||
let height = height + 6.0;
|
||||
if ui.add_sized([width, height], SelectableLabel::new(self.mini == false, "P2Pool Main")).on_hover_text(P2POOL_MAIN).clicked() { self.mini = false; }
|
||||
if ui.add_sized([width, height], SelectableLabel::new(self.mini == true, "P2Pool Mini")).on_hover_text(P2POOL_MINI).clicked() { self.mini = true; }
|
||||
if ui.add_sized([width, height], SelectableLabel::new(!self.mini, "P2Pool Main")).on_hover_text(P2POOL_MAIN).clicked() { self.mini = false; }
|
||||
if ui.add_sized([width, height], SelectableLabel::new(self.mini, "P2Pool Mini")).on_hover_text(P2POOL_MINI).clicked() { self.mini = true; }
|
||||
})});
|
||||
// [Out/In Peers] + [Log Level]
|
||||
ui.group(|ui| { ui.vertical(|ui| {
|
||||
|
|
|
@ -25,7 +25,7 @@ pub struct Status {
|
|||
}
|
||||
|
||||
impl Status {
|
||||
pub fn show(app: &mut App, width: f32, height: f32, ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
pub fn show(_app: &mut App, _width: f32, _height: f32, _ctx: &egui::Context, ui: &mut egui::Ui) {
|
||||
let color = if ui.visuals().dark_mode {
|
||||
Color32::from_additive_luminance(196)
|
||||
} else {
|
||||
|
|
143
src/update.rs
143
src/update.rs
|
@ -25,7 +25,7 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- Imports
|
||||
use anyhow::{anyhow,Error};
|
||||
use arti_client::{TorClient,TorClientConfig};
|
||||
use arti_client::{TorClient};
|
||||
use arti_hyper::*;
|
||||
use crate::constants::GUPAX_VERSION;
|
||||
//use crate::{Name::*,State};
|
||||
|
@ -64,21 +64,21 @@ use zip::ZipArchive;
|
|||
// - XMRig separates the hash and signature
|
||||
// - P2Pool hashes are in UPPERCASE
|
||||
|
||||
const GUPAX_METADATA: &'static str = "https://api.github.com/repos/hinto-janaiyo/gupax/releases/latest";
|
||||
const P2POOL_METADATA: &'static str = "https://api.github.com/repos/SChernykh/p2pool/releases/latest";
|
||||
const XMRIG_METADATA: &'static str = "https://api.github.com/repos/xmrig/xmrig/releases/latest";
|
||||
const GUPAX_METADATA: &str = "https://api.github.com/repos/hinto-janaiyo/gupax/releases/latest";
|
||||
const P2POOL_METADATA: &str = "https://api.github.com/repos/SChernykh/p2pool/releases/latest";
|
||||
const XMRIG_METADATA: &str = "https://api.github.com/repos/xmrig/xmrig/releases/latest";
|
||||
|
||||
const GUPAX_PREFIX: &'static str = "https://github.com/hinto-janaiyo/gupax/releases/download/";
|
||||
const P2POOL_PREFIX: &'static str = "https://github.com/SChernykh/p2pool/releases/download/";
|
||||
const XMRIG_PREFIX: &'static str = "https://github.com/xmrig/xmrig/releases/download/";
|
||||
const GUPAX_PREFIX: &str = "https://github.com/hinto-janaiyo/gupax/releases/download/";
|
||||
const P2POOL_PREFIX: &str = "https://github.com/SChernykh/p2pool/releases/download/";
|
||||
const XMRIG_PREFIX: &str = "https://github.com/xmrig/xmrig/releases/download/";
|
||||
|
||||
const GUPAX_SUFFIX: &'static str = "/gupax-";
|
||||
const P2POOL_SUFFIX: &'static str = "/p2pool-";
|
||||
const XMRIG_SUFFIX: &'static str = "/xmrig-";
|
||||
const GUPAX_SUFFIX: &str = "/gupax-";
|
||||
const P2POOL_SUFFIX: &str = "/p2pool-";
|
||||
const XMRIG_SUFFIX: &str = "/xmrig-";
|
||||
|
||||
const GUPAX_HASH: &'static str = "SHA256SUMS";
|
||||
const P2POOL_HASH: &'static str = "sha256sums.txt.asc";
|
||||
const XMRIG_HASH: &'static str = "SHA256SUMS";
|
||||
const GUPAX_HASH: &str = "SHA256SUMS";
|
||||
const P2POOL_HASH: &str = "sha256sums.txt.asc";
|
||||
const XMRIG_HASH: &str = "SHA256SUMS";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const GUPAX_EXTENSION: &'static str = "-windows-x64-standalone.zip";
|
||||
|
@ -95,32 +95,32 @@ const P2POOL_EXTENSION: &'static str = "-macos-x64.tar.gz";
|
|||
const XMRIG_EXTENSION: &'static str = "-macos-x64.tar.gz";
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
const GUPAX_EXTENSION: &'static str = "-linux-x64-standalone.tar.gz";
|
||||
const GUPAX_EXTENSION: &str = "-linux-x64-standalone.tar.gz";
|
||||
#[cfg(target_os = "linux")]
|
||||
const P2POOL_EXTENSION: &'static str = "-linux-x64.tar.gz";
|
||||
const P2POOL_EXTENSION: &str = "-linux-x64.tar.gz";
|
||||
#[cfg(target_os = "linux")]
|
||||
const XMRIG_EXTENSION: &'static str = "-linux-static-x64.tar.gz";
|
||||
const XMRIG_EXTENSION: &str = "-linux-static-x64.tar.gz";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const GUPAX_BINARY: &'static str = "Gupax.exe";
|
||||
#[cfg(target_os = "macos")]
|
||||
const GUPAX_BINARY: &'static str = "Gupax";
|
||||
#[cfg(target_os = "linux")]
|
||||
const GUPAX_BINARY: &'static str = "gupax";
|
||||
const GUPAX_BINARY: &str = "gupax";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const P2POOL_BINARY: &'static str = "p2pool.exe";
|
||||
#[cfg(target_family = "unix")]
|
||||
const P2POOL_BINARY: &'static str = "p2pool";
|
||||
const P2POOL_BINARY: &str = "p2pool";
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
const XMRIG_BINARY: &'static str = "xmrig.exe";
|
||||
#[cfg(target_family = "unix")]
|
||||
const XMRIG_BINARY: &'static str = "xmrig";
|
||||
const XMRIG_BINARY: &str = "xmrig";
|
||||
|
||||
// Some fake Curl/Wget user-agents because GitHub API requires one and a Tor browser
|
||||
// user-agent might be fingerprintable without all the associated headers.
|
||||
const FAKE_USER_AGENT: [&'static str; 50] = [
|
||||
const FAKE_USER_AGENT: [&str; 50] = [
|
||||
"Wget/1.16.3","Wget/1.17","Wget/1.17.1","Wget/1.18","Wget/1.18","Wget/1.19","Wget/1.19.1","Wget/1.19.2","Wget/1.19.3","Wget/1.19.4",
|
||||
"Wget/1.19.5","Wget/1.20","Wget/1.20.1","Wget/1.20.2","Wget/1.20.3","Wget/1.21","Wget/1.21.1","Wget/1.21.2","Wget/1.21.3",
|
||||
"curl/7.64.1","curl/7.65.0","curl/7.65.1","curl/7.65.2","curl/7.65.3","curl/7.66.0","curl/7.67.0","curl/7.68.0","curl/7.69.0",
|
||||
|
@ -129,28 +129,28 @@ const FAKE_USER_AGENT: [&'static str; 50] = [
|
|||
"curl/7.83.0","curl/7.83.1","curl/7.84.0","curl/7.85.0",
|
||||
];
|
||||
|
||||
const MSG_NONE: &'static str = "No update in progress";
|
||||
const MSG_START: &'static str = "Starting update";
|
||||
const MSG_TMP: &'static str = "Creating temporary directory";
|
||||
const MSG_TOR: &'static str = "Creating Tor+HTTPS client";
|
||||
const MSG_HTTPS: &'static str = "Creating HTTPS client";
|
||||
const MSG_METADATA: &'static str = "Fetching package metadata";
|
||||
const MSG_METADATA_RETRY: &'static str = "Fetching package metadata failed, attempt";
|
||||
const MSG_COMPARE: &'static str = "Compare package versions";
|
||||
const MSG_UP_TO_DATE: &'static str = "All packages already up-to-date";
|
||||
const MSG_DOWNLOAD: &'static str = "Downloading packages";
|
||||
const MSG_DOWNLOAD_RETRY: &'static str = "Downloading packages failed, attempt";
|
||||
const MSG_EXTRACT: &'static str = "Extracting packages";
|
||||
const MSG_UPGRADE: &'static str = "Upgrading packages";
|
||||
pub const MSG_SUCCESS: &'static str = "Update successful";
|
||||
pub const MSG_FAILED: &'static str = "Update failed";
|
||||
const MSG_NONE: &str = "No update in progress";
|
||||
const MSG_START: &str = "Starting update";
|
||||
const MSG_TMP: &str = "Creating temporary directory";
|
||||
const MSG_TOR: &str = "Creating Tor+HTTPS client";
|
||||
const MSG_HTTPS: &str = "Creating HTTPS client";
|
||||
const MSG_METADATA: &str = "Fetching package metadata";
|
||||
const MSG_METADATA_RETRY: &str = "Fetching package metadata failed, attempt";
|
||||
const MSG_COMPARE: &str = "Compare package versions";
|
||||
const MSG_UP_TO_DATE: &str = "All packages already up-to-date";
|
||||
const MSG_DOWNLOAD: &str = "Downloading packages";
|
||||
const MSG_DOWNLOAD_RETRY: &str = "Downloading packages failed, attempt";
|
||||
const MSG_EXTRACT: &str = "Extracting packages";
|
||||
const MSG_UPGRADE: &str = "Upgrading packages";
|
||||
pub const MSG_SUCCESS: &str = "Update successful";
|
||||
pub const MSG_FAILED: &str = "Update failed";
|
||||
|
||||
const INIT: &'static str = "------------------- Init -------------------";
|
||||
const METADATA: &'static str = "----------------- Metadata -----------------";
|
||||
const COMPARE: &'static str = "----------------- Compare ------------------";
|
||||
const DOWNLOAD: &'static str = "----------------- Download -----------------";
|
||||
const EXTRACT: &'static str = "----------------- Extract ------------------";
|
||||
const UPGRADE: &'static str = "----------------- Upgrade ------------------";
|
||||
const INIT: &str = "------------------- Init -------------------";
|
||||
const METADATA: &str = "----------------- Metadata -----------------";
|
||||
const COMPARE: &str = "----------------- Compare ------------------";
|
||||
const DOWNLOAD: &str = "----------------- Download -----------------";
|
||||
const EXTRACT: &str = "----------------- Extract ------------------";
|
||||
const UPGRADE: &str = "----------------- Upgrade ------------------";
|
||||
|
||||
// These two are sequential and not async so no need for a constant message.
|
||||
// The package in question will be known at runtime, so that will be printed.
|
||||
|
@ -239,12 +239,12 @@ impl Update {
|
|||
let tls = tls_api_native_tls::TlsConnector::builder()?.build()?;
|
||||
let connector = ArtiHttpConnector::new(tor, tls);
|
||||
let client = ClientEnum::Tor(Client::builder().build(connector));
|
||||
return Ok(client)
|
||||
Ok(client)
|
||||
} else {
|
||||
let mut connector = hyper_tls::HttpsConnector::new();
|
||||
connector.https_only(true);
|
||||
let client = ClientEnum::Https(Client::builder().build(connector));
|
||||
return Ok(client)
|
||||
Ok(client)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,14 +253,14 @@ impl Update {
|
|||
// actually contains the code. This is so that everytime
|
||||
// an update needs to happen (Gupax tab, auto-update), the
|
||||
// code only needs to be edited once, here.
|
||||
pub fn spawn_thread(og: &Arc<Mutex<State>>, update: &Arc<Mutex<Update>>, state_ver: &Arc<Mutex<Version>>, state_path: &PathBuf) {
|
||||
pub fn spawn_thread(og: &Arc<Mutex<State>>, update: &Arc<Mutex<Update>>, state_ver: &Arc<Mutex<Version>>, state_path: &Path) {
|
||||
update.lock().unwrap().path_p2pool = og.lock().unwrap().gupax.absolute_p2pool_path.display().to_string();
|
||||
update.lock().unwrap().path_xmrig = og.lock().unwrap().gupax.absolute_xmrig_path.display().to_string();
|
||||
update.lock().unwrap().tor = og.lock().unwrap().gupax.update_via_tor;
|
||||
let og = Arc::clone(&og);
|
||||
let state_ver = Arc::clone(&state_ver);
|
||||
let update = Arc::clone(&update);
|
||||
let state_path = state_path.clone();
|
||||
let og = Arc::clone(og);
|
||||
let state_ver = Arc::clone(state_ver);
|
||||
let update = Arc::clone(update);
|
||||
let state_path = state_path.to_path_buf();
|
||||
std::thread::spawn(move|| {
|
||||
info!("Spawning update thread...");
|
||||
match Update::start(update.clone(), og.clone(), state_ver.clone()) {
|
||||
|
@ -273,7 +273,7 @@ impl Update {
|
|||
Err(e) => {
|
||||
warn!("Update | Saving state ... FAIL ... {}", e);
|
||||
og.lock().unwrap().version = original_version;
|
||||
*update.lock().unwrap().msg.lock().unwrap() = format!("Saving new versions into state failed");
|
||||
*update.lock().unwrap().msg.lock().unwrap() = "Saving new versions into state failed".to_string();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ impl Update {
|
|||
// 4. loop over vec, download links
|
||||
// 5. extract, upgrade
|
||||
#[tokio::main]
|
||||
pub async fn start(update: Arc<Mutex<Self>>, og: Arc<Mutex<State>>, state_ver: Arc<Mutex<Version>>) -> Result<(), anyhow::Error> {
|
||||
pub async fn start(update: Arc<Mutex<Self>>, _og: Arc<Mutex<State>>, state_ver: Arc<Mutex<Version>>) -> Result<(), anyhow::Error> {
|
||||
//---------------------------------------------------------------------------------------------------- Init
|
||||
*update.lock().unwrap().updating.lock().unwrap() = true;
|
||||
// Set timer
|
||||
|
@ -352,7 +352,7 @@ impl Update {
|
|||
// function itself but for some reason, it was getting skipped over,
|
||||
// so the [new_ver] check is now here, in the outer scope.
|
||||
for i in 1..=3 {
|
||||
if i > 1 { *update.lock().unwrap().msg.lock().unwrap() = format!("{} [{}/3]", MSG_METADATA_RETRY.to_string(), i); }
|
||||
if i > 1 { *update.lock().unwrap().msg.lock().unwrap() = format!("{} [{}/3]", MSG_METADATA_RETRY, i); }
|
||||
let mut handles: Vec<JoinHandle<Result<(), anyhow::Error>>> = vec![];
|
||||
for pkg in vec.iter() {
|
||||
// Clone data before sending to async
|
||||
|
@ -373,10 +373,7 @@ impl Update {
|
|||
// Two [??] will send the error.
|
||||
// We don't actually want to return the error here since we
|
||||
// prefer looping and retrying over immediately erroring out.
|
||||
match handle.await? {
|
||||
Err(e) => warn!("Update | {}", e),
|
||||
_ => (),
|
||||
}
|
||||
if let Err(e) = handle.await? { warn!("Update | {}", e) }
|
||||
}
|
||||
// Check for empty version
|
||||
let mut indexes = vec![];
|
||||
|
@ -470,22 +467,20 @@ impl Update {
|
|||
info!("Update | {}", DOWNLOAD);
|
||||
let mut vec4 = vec![];
|
||||
for i in 1..=3 {
|
||||
if i > 1 { *update.lock().unwrap().msg.lock().unwrap() = format!("{} [{}/3]{}", MSG_DOWNLOAD_RETRY.to_string(), i, new_pkgs); }
|
||||
if i > 1 { *update.lock().unwrap().msg.lock().unwrap() = format!("{} [{}/3]{}", MSG_DOWNLOAD_RETRY, i, new_pkgs); }
|
||||
let mut handles: Vec<JoinHandle<Result<(), anyhow::Error>>> = vec![];
|
||||
for pkg in vec3.iter() {
|
||||
// Clone data before async
|
||||
let bytes = Arc::clone(&pkg.bytes);
|
||||
let client = client.clone();
|
||||
let version = pkg.new_ver.lock().unwrap();
|
||||
let link;
|
||||
// Download link = PREFIX + Version (found at runtime) + SUFFIX + Version + EXT
|
||||
// Example: https://github.com/hinto-janaiyo/gupax/releases/download/v0.0.1/gupax-v0.0.1-linux-x64-standalone
|
||||
// XMRig doesn't have a [v], so slice it out
|
||||
if pkg.name == Name::Xmrig {
|
||||
link = pkg.link_prefix.to_string() + &version + &pkg.link_suffix + &version[1..] + &pkg.link_extension;
|
||||
} else {
|
||||
link = pkg.link_prefix.to_string() + &version + &pkg.link_suffix + &version + &pkg.link_extension;
|
||||
}
|
||||
let link = match pkg.name {
|
||||
Name::Xmrig => pkg.link_prefix.to_string() + &version + pkg.link_suffix + &version[1..] + pkg.link_extension,
|
||||
_ => pkg.link_prefix.to_string() + &version + pkg.link_suffix + &version + pkg.link_extension,
|
||||
};
|
||||
info!("Update | {} ... {}", pkg.name, link);
|
||||
let handle: JoinHandle<Result<(), anyhow::Error>> = tokio::spawn(async move {
|
||||
match client {
|
||||
|
@ -497,10 +492,7 @@ impl Update {
|
|||
}
|
||||
// Handle await
|
||||
for handle in handles {
|
||||
match handle.await? {
|
||||
Err(e) => warn!("Update | {}", e),
|
||||
_ => (),
|
||||
}
|
||||
if let Err(e) = handle.await? { warn!("Update | {}", e) }
|
||||
}
|
||||
// Check for empty bytes
|
||||
let mut indexes = vec![];
|
||||
|
@ -534,11 +526,10 @@ impl Update {
|
|||
*update.lock().unwrap().msg.lock().unwrap() = format!("{}{}", MSG_EXTRACT, new_pkgs);
|
||||
info!("Update | {}", EXTRACT);
|
||||
for pkg in vec4.iter() {
|
||||
let tmp;
|
||||
match pkg.name {
|
||||
Name::Gupax => tmp = tmp_dir.to_owned() + GUPAX_BINARY,
|
||||
_ => tmp = tmp_dir.to_owned() + &pkg.name.to_string(),
|
||||
}
|
||||
let tmp = match pkg.name {
|
||||
Name::Gupax => tmp_dir.to_owned() + GUPAX_BINARY,
|
||||
_ => tmp_dir.to_owned() + &pkg.name.to_string(),
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
ZipArchive::extract(&mut ZipArchive::new(std::io::Cursor::new(pkg.bytes.lock().unwrap().as_ref()))?, tmp)?;
|
||||
#[cfg(target_family = "unix")]
|
||||
|
@ -563,7 +554,7 @@ impl Update {
|
|||
let entry = entry?.clone();
|
||||
// If not a file, continue
|
||||
if ! entry.file_type().is_file() { continue }
|
||||
let basename = entry.file_name().to_str().ok_or(anyhow::Error::msg("WalkDir basename failed"))?;
|
||||
let basename = entry.file_name().to_str().ok_or_else(|| anyhow::Error::msg("WalkDir basename failed"))?;
|
||||
match basename {
|
||||
GUPAX_BINARY|P2POOL_BINARY|XMRIG_BINARY => {
|
||||
found = true;
|
||||
|
@ -595,7 +586,7 @@ impl Update {
|
|||
}
|
||||
info!("Update | Moving new [{}] -> [{}]", entry.path().display(), path.display());
|
||||
if name == P2pool || name == Xmrig {
|
||||
std::fs::create_dir_all(std::path::Path::new(&path).parent().ok_or(anyhow::Error::msg(format!("{} path failed", name)))?)?;
|
||||
std::fs::create_dir_all(std::path::Path::new(&path).parent().ok_or_else(|| anyhow::Error::msg(format!("{} path failed", name)))?)?;
|
||||
}
|
||||
std::fs::rename(entry.path(), path)?;
|
||||
match name {
|
||||
|
@ -608,7 +599,7 @@ impl Update {
|
|||
_ => (),
|
||||
}
|
||||
}
|
||||
if found == false { return Err(anyhow::Error::msg("Fatal error: Package binary could not be found")) }
|
||||
if !found { return Err(anyhow::Error::msg("Fatal error: Package binary could not be found")) }
|
||||
|
||||
// Remove tmp dir (on Unix)
|
||||
#[cfg(target_family = "unix")]
|
||||
|
@ -706,7 +697,7 @@ impl Pkg {
|
|||
let mut response = client.request(request).await?;
|
||||
let body = hyper::body::to_bytes(response.body_mut()).await?;
|
||||
let body: TagName = serde_json::from_slice(&body)?;
|
||||
*new_ver.lock().unwrap() = body.tag_name.clone();
|
||||
*new_ver.lock().unwrap() = body.tag_name;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -730,7 +721,7 @@ impl Pkg {
|
|||
|
||||
// Take in a [Name] and [Vec] of [Pkg]s, find
|
||||
// that [Name]'s corresponding new version.
|
||||
fn get_new_pkg_version(name: Name, vec: &Vec<&Pkg>) -> Result<String, Error> {
|
||||
fn get_new_pkg_version(name: Name, vec: &[&Pkg]) -> Result<String, Error> {
|
||||
for pkg in vec.iter() {
|
||||
if pkg.name == name {
|
||||
return Ok(pkg.new_ver.lock().unwrap().to_string())
|
||||
|
|
16
src/xmrig.rs
16
src/xmrig.rs
|
@ -18,14 +18,13 @@
|
|||
use crate::{
|
||||
Regexes,
|
||||
constants::*,
|
||||
disk::*,
|
||||
node::*
|
||||
disk::*
|
||||
};
|
||||
use egui::{
|
||||
TextEdit,SelectableLabel,ComboBox,Label,Button,RichText,Slider,Checkbox,
|
||||
TextStyle::*,
|
||||
};
|
||||
use std::sync::{Arc,Mutex};
|
||||
|
||||
use regex::Regex;
|
||||
use log::*;
|
||||
|
||||
|
@ -42,7 +41,7 @@ impl Xmrig {
|
|||
});
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Config
|
||||
if self.simple == false {
|
||||
if !self.simple {
|
||||
ui.group(|ui| { ui.horizontal(|ui| {
|
||||
let width = (width/10.0) - SPACE;
|
||||
ui.style_mut().override_text_style = Some(Monospace);
|
||||
|
@ -62,7 +61,7 @@ impl Xmrig {
|
|||
if self.address.is_empty() {
|
||||
text = format!("Monero Address [{}/95] ➖", len);
|
||||
color = LIGHT_GRAY;
|
||||
} else if self.address.len() == 95 && Regex::is_match(®ex.address, &self.address) && ! self.address.contains("0") && ! self.address.contains("O") && ! self.address.contains("l") {
|
||||
} else if self.address.len() == 95 && Regex::is_match(®ex.address, &self.address) && ! self.address.contains('0') && ! self.address.contains('O') && ! self.address.contains('l') {
|
||||
text = format!("Monero Address [{}/95] ✔", len);
|
||||
color = GREEN;
|
||||
} else {
|
||||
|
@ -100,7 +99,7 @@ impl Xmrig {
|
|||
|
||||
// });
|
||||
} else {
|
||||
let height = height / 10.0;
|
||||
let _height = height / 10.0;
|
||||
let width = ui.available_width() - 10.0;
|
||||
let mut incorrect_input = false; // This will disable [Add/Delete] on bad input
|
||||
// [Pool IP/Port]
|
||||
|
@ -234,8 +233,7 @@ impl Xmrig {
|
|||
existing_index += 1;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let text;
|
||||
if exists { text = LIST_SAVE } else { text = LIST_ADD }
|
||||
let text = if exists { LIST_SAVE } else { LIST_ADD };
|
||||
let text = format!("{}\n Currently selected pool: {}. {}\n Current amount of pools: {}/1000", text, self.selected_index+1, self.selected_name, pool_vec_len);
|
||||
// If the pool already exists, show [Save] and mutate the already existing pool
|
||||
if exists {
|
||||
|
@ -283,7 +281,7 @@ impl Xmrig {
|
|||
}
|
||||
_ => {
|
||||
pool_vec.remove(self.selected_index);
|
||||
self.selected_index = self.selected_index-1;
|
||||
self.selected_index -= 1;
|
||||
new_name = pool_vec[self.selected_index].0.clone();
|
||||
new_pool = pool_vec[self.selected_index].1.clone();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue