feat: default to Auto mode when entered hashrate is invalid

This commit is contained in:
mostafaei2002 2024-06-06 16:55:03 +03:30
parent 74af62fd3b
commit 23a7a7f341
3 changed files with 13 additions and 3 deletions

View file

@ -18,6 +18,7 @@ use crate::helper::p2pool::ImgP2pool;
use crate::helper::p2pool::PubP2poolApi;
use crate::helper::xmrig::ImgXmrig;
use crate::helper::xmrig::PubXmrigApi;
use crate::helper::xvb::priv_stats::RuntimeMode;
use crate::helper::xvb::PubXvbApi;
use crate::helper::Helper;
use crate::helper::Process;
@ -527,7 +528,14 @@ impl App {
// Set saved Hero mode to runtime.
debug!("Setting runtime_mode & runtime_manual_amount");
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into();
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = app.state.xvb.amount.parse().unwrap();
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = match app.state.xvb.amount.parse() {
Ok(n) => n,
Err(e) => {
error!("App Init | Failed to parse manual amount: {}", e);
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = RuntimeMode::Auto;
0
}
};
// Check if [P2pool.node] exists
info!("App Init | Checking if saved remote node still exists...");

View file

@ -16,7 +16,7 @@ use crate::utils::constants::{
};
use crate::utils::macros::lock;
use crate::utils::regex::Regexes;
use crate::XVB_MINING_ON_FIELD;
use crate::{XVB_MANUAL_HASHRATE_HELP, XVB_MINING_ON_FIELD};
use crate::{
constants::{BYTES_XVB, SPACE},
utils::constants::{DARK_GRAY, XVB_URL},
@ -130,7 +130,8 @@ impl crate::disk::state::Xvb {
ui.horizontal(|ui| {
ui.add(
TextEdit::singleline(&mut self.amount)
)
.vertical_align(egui::Align::Center)
).on_hover_text(XVB_MANUAL_HASHRATE_HELP)
});
}

View file

@ -412,6 +412,7 @@ pub const XMRIG_PATH_EMPTY: &str = "XMRig PATH is empty! To fix: goto the [G
// XvB
pub const XVB_HELP: &str = "You need to register an account by clicking on the link above to get your token with the same p2pool XMR address you use for payment.";
pub const XVB_MANUAL_HASHRATE_HELP: &str = "Set the hashrate amount to donate or keep manually in H/s";
pub const XVB_URL: &str = "https://xmrvsbeast.com";
pub const XVB_URL_PUBLIC_API: &str = "https://xmrvsbeast.com/p2pool/stats";