diff --git a/src/app/panels/middle/xvb.rs b/src/app/panels/middle/xvb.rs index 89bd704..8a6b442 100644 --- a/src/app/panels/middle/xvb.rs +++ b/src/app/panels/middle/xvb.rs @@ -6,7 +6,7 @@ use log::debug; use readable::num::Float; use readable::up::Uptime; -use crate::disk::state::XvbMode; +use crate::disk::state::{XvbMode, ManualDonationLevel}; use crate::helper::xmrig::PubXmrigApi; use crate::helper::xvb::priv_stats::RuntimeMode; use crate::helper::xvb::PubXvbApi; @@ -134,7 +134,11 @@ impl crate::disk::state::Xvb { } } - +}); + + + ui.add_space(space_h); + // --------------------------- XVB Advanced ----------------------------------------- if !self.simple { @@ -149,6 +153,7 @@ impl crate::disk::state::Xvb { ui.selectable_value(&mut self.mode, XvbMode::Hero, "Hero Mode"); ui.selectable_value(&mut self.mode, XvbMode::ManuallyDonate, "Manually Donate"); ui.selectable_value(&mut self.mode, XvbMode::ManuallyKeep, "Manually Keep"); + ui.selectable_value(&mut self.mode, XvbMode::ManualDonationLevel, "Manual Donation Level"); }); if self.mode == XvbMode::ManuallyDonate || self.mode == XvbMode::ManuallyKeep { @@ -167,6 +172,17 @@ impl crate::disk::state::Xvb { ui.add( egui::Slider::new(&mut self.amount, 0.0..=(hashrate_xmrig as f64)).text("H/s") ).on_hover_text(XVB_MANUAL_HASHRATE_HELP); + + } + + if self.mode == XvbMode::ManualDonationLevel { + ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::VIP, "VIP"); + ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::Donor, "Donor"); + ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::DonorVIP, "DonorVIP"); + ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::DonorWhale, "DonorWhale"); + ui.radio_value(&mut self.manual_donation_level, ManualDonationLevel::DonorMega, "DonorMega"); + + lock!(api).stats_priv.runtime_manual_donation_level = self.manual_donation_level.clone().into(); } }); @@ -177,8 +193,6 @@ impl crate::disk::state::Xvb { lock!(api).stats_priv.runtime_mode = self.mode.clone().into(); lock!(api).stats_priv.runtime_manual_amount = self.amount; } - -}); // need to warn the user if no address is set in p2pool tab if !Regexes::addr_ok(address) { diff --git a/src/disk/state.rs b/src/disk/state.rs index 91029c4..5cf6121 100644 --- a/src/disk/state.rs +++ b/src/disk/state.rs @@ -249,6 +249,17 @@ pub enum XvbMode { ManuallyDonate, ManuallyKeep, Hero, + ManualDonationLevel +} + + +#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)] +pub enum ManualDonationLevel { + VIP, + Donor, + DonorVIP, + DonorWhale, + DonorMega } #[derive(Clone, PartialEq, Debug, Deserialize, Serialize, Default)] @@ -257,7 +268,8 @@ pub struct Xvb { pub token: String, pub simple_hero_mode: bool, pub mode: XvbMode, - pub amount: f64 + pub amount: f64, + pub manual_donation_level: ManualDonationLevel } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -391,4 +403,10 @@ impl Default for XvbMode { fn default() -> Self { Self::Auto } +} + +impl Default for ManualDonationLevel { + fn default() -> Self { + Self::VIP + } } \ No newline at end of file diff --git a/src/helper/xvb/algorithm.rs b/src/helper/xvb/algorithm.rs index b3cc308..52db839 100644 --- a/src/helper/xvb/algorithm.rs +++ b/src/helper/xvb/algorithm.rs @@ -93,6 +93,9 @@ pub(crate) fn calcul_donated_time( info!("RuntimeMode::ManuallyDonate - lhr:{lhr} keep_hr:{keep_hr}"); XVB_TIME_ALGO - (XVB_TIME_ALGO * (keep_hr as u32) / (lhr as u32)) + }, + RuntimeMode::ManualDonationLevel => { + todo!() } }; diff --git a/src/helper/xvb/priv_stats.rs b/src/helper/xvb/priv_stats.rs index 0f6277a..4496a4e 100644 --- a/src/helper/xvb/priv_stats.rs +++ b/src/helper/xvb/priv_stats.rs @@ -10,9 +10,7 @@ use serde::Deserialize; use tokio::time::sleep; use crate::{ - helper::{xvb::output_console, Process, ProcessState}, - macros::lock, - XVB_URL, + disk::state::ManualDonationLevel, helper::{xvb::output_console, Process, ProcessState}, macros::lock, XVB_URL }; use crate::disk::state::XvbMode; @@ -25,6 +23,17 @@ pub enum RuntimeMode { ManuallyDonate, ManuallyKeep, Hero, + ManualDonationLevel +} + + +#[derive(Debug, Clone, Deserialize, PartialEq, Eq)] +pub enum RuntimeDonationLevel { + VIP, + Donor, + DonorVIP, + DonorWhale, + DonorMega } #[derive(Debug, Clone, Default, Deserialize)] @@ -48,7 +57,9 @@ pub struct XvbPrivStats { // so the hero mode can change between two decision of algorithm without restarting XvB. pub runtime_mode: RuntimeMode, #[serde(skip)] - pub runtime_manual_amount: f64 + pub runtime_manual_amount: f64, + #[serde(skip)] + pub runtime_manual_donation_level: RuntimeDonationLevel } impl XvbPrivStats { @@ -126,6 +137,19 @@ impl From for RuntimeMode { XvbMode::ManuallyDonate => Self::ManuallyDonate, XvbMode::ManuallyKeep => Self::ManuallyKeep, XvbMode::Hero => Self::Hero, + XvbMode::ManualDonationLevel => Self::ManualDonationLevel + } + } +} + +impl From for RuntimeDonationLevel { + fn from(level: ManualDonationLevel) -> Self { + match level { + ManualDonationLevel::VIP => RuntimeDonationLevel::VIP, + ManualDonationLevel::Donor => RuntimeDonationLevel::Donor, + ManualDonationLevel::DonorVIP => RuntimeDonationLevel::DonorVIP, + ManualDonationLevel::DonorWhale => RuntimeDonationLevel::DonorWhale, + ManualDonationLevel::DonorMega => RuntimeDonationLevel::DonorMega } } } @@ -134,4 +158,10 @@ impl Default for RuntimeMode { fn default() -> Self { Self::Auto } +} + +impl Default for RuntimeDonationLevel { + fn default() -> Self { + Self::VIP + } } \ No newline at end of file