mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
fix: formatting
This commit is contained in:
parent
f2a3c00145
commit
a450f1e684
9 changed files with 73 additions and 73 deletions
|
@ -527,7 +527,8 @@ 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.manual_amount_raw;
|
||||
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount =
|
||||
app.state.xvb.manual_amount_raw;
|
||||
// Check if [P2pool.node] exists
|
||||
info!("App Init | Checking if saved remote node still exists...");
|
||||
app.state.p2pool.node = RemoteNode::check_exists(&app.state.p2pool.node);
|
||||
|
|
|
@ -122,7 +122,7 @@ impl crate::app::App {
|
|||
key,
|
||||
wants_input,
|
||||
);
|
||||
},
|
||||
}
|
||||
Tab::About => {}
|
||||
}
|
||||
});
|
||||
|
@ -510,7 +510,7 @@ impl crate::app::App {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
fn xvb_submenu(&mut self, ui: &mut Ui, size: Vec2) {
|
||||
ui.group(|ui| {
|
||||
let width = size.x / 1.5;
|
||||
|
@ -526,10 +526,7 @@ impl crate::app::App {
|
|||
}
|
||||
ui.separator();
|
||||
if ui
|
||||
.add_sized(
|
||||
size,
|
||||
SelectableLabel::new(self.state.xvb.simple, "Simple"),
|
||||
)
|
||||
.add_sized(size, SelectableLabel::new(self.state.xvb.simple, "Simple"))
|
||||
.clicked()
|
||||
{
|
||||
self.state.xvb.simple = true;
|
||||
|
@ -613,7 +610,6 @@ impl crate::app::App {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn status_p2pool(state: ProcessState, ui: &mut Ui, size: Vec2) {
|
||||
|
|
|
@ -6,21 +6,23 @@ use log::debug;
|
|||
use readable::num::Float;
|
||||
use readable::up::Uptime;
|
||||
|
||||
use crate::disk::state::{XvbMode, ManualDonationLevel, ManualDonationMetric};
|
||||
use crate::disk::state::{ManualDonationLevel, ManualDonationMetric, XvbMode};
|
||||
use crate::helper::xmrig::PubXmrigApi;
|
||||
use crate::helper::xvb::priv_stats::RuntimeMode;
|
||||
use crate::helper::xvb::PubXvbApi;
|
||||
use crate::regex::num_lines;
|
||||
use crate::utils::constants::{
|
||||
GREEN, LIGHT_GRAY, ORANGE, RED, XVB_DONATED_1H_FIELD, XVB_DONATED_24H_FIELD, XVB_FAILURE_FIELD,
|
||||
XVB_HELP, XVB_ROUND_TYPE_FIELD, XVB_TOKEN_FIELD, XVB_TOKEN_LEN, XVB_URL_RULES,
|
||||
XVB_WINNER_FIELD, XVB_HERO_SELECT, XVB_MODE_MANUAL_XVB_HELP, XVB_MODE_MANUAL_P2POOL_HELP, XVB_MODE_MANUAL_DONATION_LEVEL_HELP,
|
||||
XVB_DONATION_LEVEL_DONOR_HELP, XVB_DONATION_LEVEL_VIP_DONOR_HELP, XVB_DONATION_LEVEL_WHALE_DONOR_HELP,
|
||||
XVB_DONATION_LEVEL_MEGA_DONOR_HELP, XVB_MANUAL_SLIDER_MANUAL_XVB_HELP, XVB_MANUAL_SLIDER_MANUAL_P2POOL_HELP
|
||||
GREEN, LIGHT_GRAY, ORANGE, RED, XVB_DONATED_1H_FIELD, XVB_DONATED_24H_FIELD,
|
||||
XVB_DONATION_LEVEL_DONOR_HELP, XVB_DONATION_LEVEL_MEGA_DONOR_HELP,
|
||||
XVB_DONATION_LEVEL_VIP_DONOR_HELP, XVB_DONATION_LEVEL_WHALE_DONOR_HELP, XVB_FAILURE_FIELD,
|
||||
XVB_HELP, XVB_HERO_SELECT, XVB_MANUAL_SLIDER_MANUAL_P2POOL_HELP,
|
||||
XVB_MANUAL_SLIDER_MANUAL_XVB_HELP, XVB_MODE_MANUAL_DONATION_LEVEL_HELP,
|
||||
XVB_MODE_MANUAL_P2POOL_HELP, XVB_MODE_MANUAL_XVB_HELP, XVB_ROUND_TYPE_FIELD, XVB_TOKEN_FIELD,
|
||||
XVB_TOKEN_LEN, XVB_URL_RULES, XVB_WINNER_FIELD,
|
||||
};
|
||||
use crate::utils::macros::lock;
|
||||
use crate::utils::regex::Regexes;
|
||||
use crate::{XVB_MINING_ON_FIELD};
|
||||
use crate::XVB_MINING_ON_FIELD;
|
||||
use crate::{
|
||||
constants::{BYTES_XVB, SPACE},
|
||||
utils::constants::{DARK_GRAY, XVB_URL},
|
||||
|
@ -127,7 +129,6 @@ impl crate::disk::state::Xvb {
|
|||
ui.style_mut().spacing.icon_width = width / 35.0;
|
||||
ui.style_mut().spacing.icon_spacing = space_h;
|
||||
|
||||
|
||||
// --------------------------- XVB Simple -------------------------------------------
|
||||
if self.simple {
|
||||
|
||||
|
@ -180,8 +181,6 @@ impl crate::disk::state::Xvb {
|
|||
1000.0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Adjust maximum slider amount based on slider metric
|
||||
if self.manual_donation_metric == ManualDonationMetric::Kilo {
|
||||
hashrate_xmrig /= 1000.0;
|
||||
|
@ -216,11 +215,8 @@ impl crate::disk::state::Xvb {
|
|||
self.manual_donation_metric = ManualDonationMetric::Mega;
|
||||
self.manual_slider_amount = self.manual_amount_raw / 1_000_000.0;
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if self.mode == XvbMode::ManualDonationLevel {
|
||||
|
@ -232,14 +228,13 @@ impl crate::disk::state::Xvb {
|
|||
.on_hover_text(XVB_DONATION_LEVEL_WHALE_DONOR_HELP);
|
||||
ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::DonorMega, "DonorMega")
|
||||
.on_hover_text(XVB_DONATION_LEVEL_MEGA_DONOR_HELP);
|
||||
|
||||
|
||||
lock!(api).stats_priv.runtime_manual_donation_level = self.manual_donation_level.clone().into();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Update manual_amount_raw based on slider
|
||||
match self.manual_donation_metric {
|
||||
ManualDonationMetric::Hash => {
|
||||
|
@ -256,7 +251,7 @@ impl crate::disk::state::Xvb {
|
|||
// Set runtime_mode & runtime_manual_amount
|
||||
lock!(api).stats_priv.runtime_mode = self.mode.clone().into();
|
||||
lock!(api).stats_priv.runtime_manual_amount = self.manual_amount_raw;
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_space(space_h);
|
||||
// need to warn the user if no address is set in p2pool tab
|
||||
|
@ -264,11 +259,9 @@ impl crate::disk::state::Xvb {
|
|||
debug!("XvB Tab | Rendering warning text");
|
||||
ui.horizontal_wrapped(|ui|{
|
||||
ui.label(RichText::new("You don't have any payout address set in the P2pool Tab ! XvB process needs one to function properly.")
|
||||
.color(ORANGE));
|
||||
|
||||
.color(ORANGE));
|
||||
});
|
||||
}
|
||||
|
||||
// private stats
|
||||
ui.add_space(space_h);
|
||||
// ui.add_enabled_ui(is_alive, |ui| {
|
||||
|
|
|
@ -279,7 +279,7 @@ pub enum ManualDonationMetric {
|
|||
#[default]
|
||||
Hash,
|
||||
Kilo,
|
||||
Mega
|
||||
Mega,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
|
|
|
@ -3,7 +3,10 @@ mod test {
|
|||
|
||||
use crate::helper::{
|
||||
p2pool::{PrivP2poolLocalApi, PrivP2poolNetworkApi},
|
||||
xvb::{algorithm::calcul_donated_time, priv_stats::RuntimeMode, priv_stats::RuntimeDonationLevel, rounds::round_type},
|
||||
xvb::{
|
||||
algorithm::calcul_donated_time, priv_stats::RuntimeDonationLevel,
|
||||
priv_stats::RuntimeMode, rounds::round_type,
|
||||
},
|
||||
Helper, Process, ProcessName, ProcessState,
|
||||
};
|
||||
|
||||
|
@ -778,9 +781,9 @@ Uptime = 0h 2m 4s
|
|||
/ 1000.0;
|
||||
assert_eq!(round_type(share, &gui_api_xvb), Some(XvbRound::DonorVip));
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_xvb_advanced_options () {
|
||||
fn test_xvb_advanced_options() {
|
||||
let gui_api_xvb = Arc::new(Mutex::new(PubXvbApi::new()));
|
||||
let gui_api_p2pool = Arc::new(Mutex::new(PubP2poolApi::new()));
|
||||
let gui_api_xmrig = Arc::new(Mutex::new(PubXmrigApi::new()));
|
||||
|
@ -790,17 +793,16 @@ Uptime = 0h 2m 4s
|
|||
lock!(gui_api_xmrig).hashrate_raw_15m = 5000.0;
|
||||
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualXvb;
|
||||
lock!(gui_api_xvb).stats_priv.runtime_manual_amount = 500.0;
|
||||
|
||||
|
||||
let given_time = calcul_donated_time(
|
||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||
&gui_api_p2pool,
|
||||
&gui_api_xvb,
|
||||
&state_p2pool,
|
||||
);
|
||||
|
||||
|
||||
assert_eq!(given_time, 60);
|
||||
|
||||
|
||||
|
||||
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualP2pool;
|
||||
|
||||
let given_time = calcul_donated_time(
|
||||
|
@ -810,12 +812,10 @@ Uptime = 0h 2m 4s
|
|||
&state_p2pool,
|
||||
);
|
||||
assert_eq!(given_time, 540);
|
||||
|
||||
|
||||
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualDonationLevel;
|
||||
lock!(gui_api_xvb).stats_priv.runtime_manual_donation_level = RuntimeDonationLevel::Donor;
|
||||
|
||||
|
||||
|
||||
let given_time = calcul_donated_time(
|
||||
lock!(gui_api_xmrig).hashrate_raw_15m,
|
||||
&gui_api_p2pool,
|
||||
|
@ -823,6 +823,5 @@ Uptime = 0h 2m 4s
|
|||
&state_p2pool,
|
||||
);
|
||||
assert_eq!(given_time, 120);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ use crate::{
|
|||
helper::{
|
||||
p2pool::PubP2poolApi,
|
||||
xmrig::{PrivXmrigApi, PubXmrigApi},
|
||||
xvb::{nodes::XvbNode, output_console, output_console_without_time, priv_stats::RuntimeMode},
|
||||
xvb::{
|
||||
nodes::XvbNode, output_console, output_console_without_time, priv_stats::RuntimeMode,
|
||||
},
|
||||
},
|
||||
macros::lock,
|
||||
BLOCK_PPLNS_WINDOW_MAIN, BLOCK_PPLNS_WINDOW_MINI, SECOND_PER_BLOCK_P2POOL, XMRIG_CONFIG_URI,
|
||||
|
@ -77,28 +79,31 @@ pub(crate) fn calcul_donated_time(
|
|||
info!("RuntimeMode::Auto - calculating spared_time");
|
||||
// calculate how much time needed to be spared to be in most round type minimum HR + buffer
|
||||
minimum_time_for_highest_accessible_round(default_spared_time, lhr, xvb_chr, shr)
|
||||
},
|
||||
}
|
||||
RuntimeMode::Hero => {
|
||||
info!("RuntimeMode::Hero - calculating spared_time lhr:{lhr} min_hr:{min_hr}");
|
||||
output_console(gui_api_xvb, "Hero mode is enabled for this decision");
|
||||
default_spared_time
|
||||
},
|
||||
}
|
||||
RuntimeMode::ManualXvb => {
|
||||
let donate_hr = lock!(gui_api_xvb).stats_priv.runtime_manual_amount;
|
||||
info!("RuntimeMode::ManualXvb - lhr:{lhr} donate_hr:{donate_hr}");
|
||||
|
||||
XVB_TIME_ALGO * (donate_hr as u32) / (lhr as u32)
|
||||
},
|
||||
}
|
||||
RuntimeMode::ManualP2pool => {
|
||||
let keep_hr = lock!(gui_api_xvb).stats_priv.runtime_manual_amount;
|
||||
info!("RuntimeMode::ManualXvb - lhr:{lhr} keep_hr:{keep_hr}");
|
||||
|
||||
XVB_TIME_ALGO - (XVB_TIME_ALGO * (keep_hr as u32) / (lhr as u32))
|
||||
},
|
||||
}
|
||||
RuntimeMode::ManualDonationLevel => {
|
||||
let donation_level = lock!(gui_api_xvb).stats_priv.runtime_manual_donation_level.clone();
|
||||
let donation_level = lock!(gui_api_xvb)
|
||||
.stats_priv
|
||||
.runtime_manual_donation_level
|
||||
.clone();
|
||||
info!("RuntimeMode::ManualDonationLevel");
|
||||
|
||||
|
||||
minimum_time_for_manual_round(donation_level, default_spared_time, lhr, xvb_chr, shr)
|
||||
}
|
||||
};
|
||||
|
@ -203,35 +208,39 @@ fn minimum_time_for_highest_accessible_round(st: u32, lhr: f32, chr: f32, shr: f
|
|||
(((hr_for_xvb - (hr_for_xvb - min)) / lhr) * XVB_TIME_ALGO as f32).ceil() as u32
|
||||
}
|
||||
|
||||
fn minimum_time_for_manual_round(level: RuntimeDonationLevel, st: u32, lhr: f32, chr: f32, shr: f32) -> u32 {
|
||||
fn minimum_time_for_manual_round(
|
||||
level: RuntimeDonationLevel,
|
||||
st: u32,
|
||||
lhr: f32,
|
||||
chr: f32,
|
||||
shr: f32,
|
||||
) -> u32 {
|
||||
let hr_for_xvb = ((st - 1) as f32 / XVB_TIME_ALGO as f32) * lhr;
|
||||
info!(
|
||||
"hr for xvb is: ({st} / {}) * {lhr} = {hr_for_xvb}H/s",
|
||||
XVB_TIME_ALGO
|
||||
);
|
||||
let ohr = chr - shr;
|
||||
|
||||
|
||||
let min = match level {
|
||||
RuntimeDonationLevel::Donor => {
|
||||
info!("RuntimeDonationLevel::Donor");
|
||||
XVB_ROUND_DONOR_MIN_HR as f32 - ohr
|
||||
},
|
||||
}
|
||||
RuntimeDonationLevel::DonorVIP => {
|
||||
info!("RuntimeDonationLevel::DonorVIP");
|
||||
XVB_ROUND_DONOR_VIP_MIN_HR as f32 - ohr
|
||||
},
|
||||
}
|
||||
RuntimeDonationLevel::DonorWhale => {
|
||||
info!("RuntimeDonationLevel::DonorWhale");
|
||||
XVB_ROUND_DONOR_WHALE_MIN_HR as f32 - ohr
|
||||
},
|
||||
}
|
||||
RuntimeDonationLevel::DonorMega => {
|
||||
info!("RuntimeDonationLevel::DonorMega");
|
||||
XVB_ROUND_DONOR_MEGA_MIN_HR as f32 - ohr
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
(((hr_for_xvb - (hr_for_xvb - min)) / lhr) * XVB_TIME_ALGO as f32).ceil() as u32
|
||||
}
|
||||
|
||||
|
|
|
@ -402,7 +402,6 @@ impl PubXvbApi {
|
|||
}
|
||||
let runtime_mode = std::mem::take(&mut gui_api.stats_priv.runtime_mode);
|
||||
let runtime_manual_amount = std::mem::take(&mut gui_api.stats_priv.runtime_manual_amount);
|
||||
|
||||
|
||||
*gui_api = Self {
|
||||
output,
|
||||
|
@ -700,7 +699,7 @@ fn reset_data_xvb(pub_api: &Arc<Mutex<PubXvbApi>>, gui_api: &Arc<Mutex<PubXvbApi
|
|||
let current_node = mem::take(&mut lock!(pub_api).current_node.clone());
|
||||
let runtime_mode = mem::take(&mut lock!(gui_api).stats_priv.runtime_mode);
|
||||
let runtime_manual_amount = mem::take(&mut lock!(gui_api).stats_priv.runtime_manual_amount);
|
||||
|
||||
|
||||
// let output = mem::take(&mut lock!(gui_api).output);
|
||||
*lock!(pub_api) = PubXvbApi::new();
|
||||
*lock!(gui_api) = PubXvbApi::new();
|
||||
|
|
|
@ -9,14 +9,16 @@ use reqwest::{Client, StatusCode};
|
|||
use serde::Deserialize;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::{
|
||||
disk::state::ManualDonationLevel, helper::{xvb::output_console, Process, ProcessState}, macros::lock, XVB_URL
|
||||
};
|
||||
use crate::disk::state::XvbMode;
|
||||
use crate::{
|
||||
disk::state::ManualDonationLevel,
|
||||
helper::{xvb::output_console, Process, ProcessState},
|
||||
macros::lock,
|
||||
XVB_URL,
|
||||
};
|
||||
|
||||
use super::{nodes::XvbNode, rounds::XvbRound, PubXvbApi};
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Default)]
|
||||
pub enum RuntimeMode {
|
||||
#[default]
|
||||
|
@ -24,17 +26,16 @@ pub enum RuntimeMode {
|
|||
ManualXvb,
|
||||
ManualP2pool,
|
||||
Hero,
|
||||
ManualDonationLevel
|
||||
ManualDonationLevel,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Default)]
|
||||
pub enum RuntimeDonationLevel {
|
||||
#[default]
|
||||
Donor,
|
||||
DonorVIP,
|
||||
DonorWhale,
|
||||
DonorMega
|
||||
DonorMega,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
|
@ -60,7 +61,7 @@ pub struct XvbPrivStats {
|
|||
#[serde(skip)]
|
||||
pub runtime_manual_amount: f64,
|
||||
#[serde(skip)]
|
||||
pub runtime_manual_donation_level: RuntimeDonationLevel
|
||||
pub runtime_manual_donation_level: RuntimeDonationLevel,
|
||||
}
|
||||
|
||||
impl XvbPrivStats {
|
||||
|
@ -138,7 +139,7 @@ impl From<XvbMode> for RuntimeMode {
|
|||
XvbMode::ManualXvb => Self::ManualXvb,
|
||||
XvbMode::ManualP2pool => Self::ManualP2pool,
|
||||
XvbMode::Hero => Self::Hero,
|
||||
XvbMode::ManualDonationLevel => Self::ManualDonationLevel
|
||||
XvbMode::ManualDonationLevel => Self::ManualDonationLevel,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +150,7 @@ impl From<ManualDonationLevel> for RuntimeDonationLevel {
|
|||
ManualDonationLevel::Donor => RuntimeDonationLevel::Donor,
|
||||
ManualDonationLevel::DonorVIP => RuntimeDonationLevel::DonorVIP,
|
||||
ManualDonationLevel::DonorWhale => RuntimeDonationLevel::DonorWhale,
|
||||
ManualDonationLevel::DonorMega => RuntimeDonationLevel::DonorMega
|
||||
ManualDonationLevel::DonorMega => RuntimeDonationLevel::DonorMega,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -447,13 +447,15 @@ pub const XVB_MODE_MANUAL_XVB_HELP: &str = "Manually set the amount to donate to
|
|||
pub const XVB_MODE_MANUAL_P2POOL_HELP: &str = "Manually set the amount to keep on P2pool, If value is more than xmrig hashrate it might be changed";
|
||||
pub const XVB_MODE_MANUAL_DONATION_LEVEL_HELP: &str = "Manually set the XvB donation level";
|
||||
|
||||
|
||||
// Manual Donation Levels
|
||||
pub const XVB_DONATION_LEVEL_DONOR_HELP: &str = "To qualify at least 1 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_VIP_DONOR_HELP: &str = "To qualify at least 10 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_WHALE_DONOR_HELP: &str = "To qualify at least 100 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_MEGA_DONOR_HELP: &str = "To qualify at least 1000 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
|
||||
pub const XVB_DONATION_LEVEL_DONOR_HELP: &str =
|
||||
"To qualify at least 1 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_VIP_DONOR_HELP: &str =
|
||||
"To qualify at least 10 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_WHALE_DONOR_HELP: &str =
|
||||
"To qualify at least 100 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
pub const XVB_DONATION_LEVEL_MEGA_DONOR_HELP: &str =
|
||||
"To qualify at least 1000 kH/s will be actively donated (1hr and 24hr avg.)";
|
||||
|
||||
// CLI argument messages
|
||||
pub const ARG_HELP: &str = r#"USAGE: ./gupaxx [--flag]
|
||||
|
|
Loading…
Reference in a new issue