feat: add slider to manage p2pool buffer in advanced XvB tab

This commit is contained in:
Cyrix126 2024-08-29 15:03:02 +02:00
parent 5ef98e9ab8
commit 6c7e39f20c
7 changed files with 43 additions and 8 deletions

View file

@ -265,6 +265,15 @@ 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);
// allow user to modify the buffer for p2pool
// button
ui.add_sized(
[width, text_edit],
egui::Slider::new(&mut self.p2pool_buffer, -100..=100)
.text("% P2Pool Buffer" )
).on_hover_text("Set the % amount of additional HR to send to p2pool. Will reduce (if positive) or augment (if negative) the chances to miss the p2pool window");
}
ui.add_space(space_h);

View file

@ -318,6 +318,7 @@ pub struct Xvb {
pub manual_slider_amount: f64,
pub manual_donation_level: ManualDonationLevel,
pub manual_donation_metric: ManualDonationMetric,
pub p2pool_buffer: i8,
}
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize, Default)]
@ -517,6 +518,7 @@ impl Default for Xvb {
manual_slider_amount: Default::default(),
manual_donation_level: Default::default(),
manual_donation_metric: Default::default(),
p2pool_buffer: 5,
}
}
}

View file

@ -135,6 +135,7 @@ mod test {
token = ""
hero = false
node = "Europe"
p2pool_buffer = 5
[version]
gupax = "v1.3.0"

View file

@ -543,6 +543,7 @@ Uptime = 0h 2m 4s
let rig = "test_rig";
let xp_alive = false;
let share = 1;
let p2pool_buffer = 5;
lock!(gui_api_xmrig).hashrate_raw_15m = 10000.0;
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualXvb;
@ -561,6 +562,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 1000.0);
@ -580,6 +582,7 @@ Uptime = 0h 2m 4s
let rig = "test_rig";
let xp_alive = false;
let share = 1;
let p2pool_buffer = 5;
lock!(gui_api_xmrig).hashrate_raw_15m = 10000.0;
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualP2pool;
@ -598,6 +601,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 9000.0);
@ -617,6 +621,7 @@ Uptime = 0h 2m 4s
let rig = "test_rig";
let xp_alive = false;
let share = 1;
let p2pool_buffer = 5;
lock!(gui_api_xmrig).hashrate_raw_15m = 10000.0;
lock!(gui_api_xvb).stats_priv.runtime_mode = RuntimeMode::ManualDonationLevel;
@ -636,6 +641,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 1000.0);
@ -655,6 +661,7 @@ Uptime = 0h 2m 4s
let rig = "test_rig";
let xp_alive = false;
let share = 1;
let p2pool_buffer = 5;
lock!(gui_api_p2pool).p2pool_difficulty_u64 = 9_000_000;
lock!(gui_api_xmrig).hashrate_raw_15m = 20000.0;
@ -673,6 +680,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 10000.0);
@ -694,6 +702,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 1000.0);
@ -713,6 +722,7 @@ Uptime = 0h 2m 4s
let rig = "test_rig";
let xp_alive = false;
let share = 1;
let p2pool_buffer = 5;
lock!(gui_api_p2pool).p2pool_difficulty_u64 = 95_000_000;
lock!(gui_api_xmrig).hashrate_raw_15m = 20000.0;
@ -731,6 +741,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 15382.1);
@ -750,6 +761,7 @@ Uptime = 0h 2m 4s
&time_donated,
rig,
xp_alive,
p2pool_buffer,
);
assert_eq!(algo.stats.target_donation_hashrate, 20000.0);

View file

@ -19,7 +19,7 @@ use crate::{
xvb::{nodes::XvbNode, priv_stats::RuntimeMode},
},
macros::lock,
BLOCK_PPLNS_WINDOW_MAIN, BLOCK_PPLNS_WINDOW_MINI, SECOND_PER_BLOCK_P2POOL, XVB_BUFFER,
BLOCK_PPLNS_WINDOW_MAIN, BLOCK_PPLNS_WINDOW_MINI, SECOND_PER_BLOCK_P2POOL,
XVB_ROUND_DONOR_MEGA_MIN_HR, XVB_ROUND_DONOR_MIN_HR, XVB_ROUND_DONOR_VIP_MIN_HR,
XVB_ROUND_DONOR_WHALE_MIN_HR, XVB_TIME_ALGO,
};
@ -40,6 +40,7 @@ pub(crate) async fn algorithm(
time_donated: &Arc<Mutex<u32>>,
rig: &str,
xp_alive: bool,
p2pool_buffer: i8,
) {
let mut algorithm = Algorithm::new(
client,
@ -54,6 +55,7 @@ pub(crate) async fn algorithm(
time_donated,
rig,
xp_alive,
p2pool_buffer,
);
algorithm.run().await;
}
@ -111,6 +113,7 @@ impl<'a> Algorithm<'a> {
time_donated: &'a Arc<Mutex<u32>>,
rig: &'a str,
xp_alive: bool,
p2pool_buffer: i8,
) -> Self {
let hashrate_xmrig = current_controllable_hr(xp_alive, gui_api_xp, gui_api_xmrig);
@ -136,6 +139,7 @@ impl<'a> Algorithm<'a> {
lock!(gui_api_p2pool).p2pool_difficulty_u64,
state_p2pool.mini,
p2pool_external_hashrate,
p2pool_buffer,
);
let spareable_hashrate = hashrate_xmrig - share_min_hashrate;
@ -459,20 +463,27 @@ impl<'a> Algorithm<'a> {
samples.0.iter().sum::<f32>() / samples.0.len() as f32
}
fn minimum_hashrate_share(difficulty: u64, mini: bool, p2pool_external_hashrate: f32) -> f32 {
fn minimum_hashrate_share(
difficulty: u64,
mini: bool,
p2pool_external_hashrate: f32,
p2pool_buffer: i8,
) -> f32 {
let pws = if mini {
BLOCK_PPLNS_WINDOW_MINI
} else {
BLOCK_PPLNS_WINDOW_MAIN
};
let mut minimum_hr = ((difficulty / (pws * SECOND_PER_BLOCK_P2POOL)) as f32 * XVB_BUFFER)
let mut minimum_hr = ((difficulty / (pws * SECOND_PER_BLOCK_P2POOL)) as f32
* (1.0 + (p2pool_buffer as f32 / 100.0)) as f32)
// * 1.05)
- p2pool_external_hashrate;
info!("Algorithm | (difficulty({}) / (window pplns blocks({}) * seconds per p2pool block({})) * BUFFER({})) - outside HR({}H/s) = minimum HR({}H/s) to keep a share.",
info!("Algorithm | (difficulty({}) / (window pplns blocks({}) * seconds per p2pool block({})) * (BUFFER({})) / 100) - outside HR({}H/s) = minimum HR({}H/s) to keep a share.",
difficulty,
pws,
SECOND_PER_BLOCK_P2POOL,
XVB_BUFFER,
p2pool_buffer,
p2pool_external_hashrate,
minimum_hr);

View file

@ -326,7 +326,7 @@ impl Helper {
*lock!(retry) = false;
// reset instant because algo will start.
*lock!(last_algorithm) = Instant::now();
*lock!(handle_algo) = Some(spawn(enc!((client, gui_api, gui_api_xmrig, gui_api_xp, state_xmrig, state_xp, time_donated) async move {
*lock!(handle_algo) = Some(spawn(enc!((client, gui_api, gui_api_xmrig, gui_api_xp, state_xmrig, state_xp, time_donated, state_xvb) async move {
let token_xmrig = if xp_alive {
&state_xp.token
} else {
@ -349,7 +349,8 @@ impl Helper {
share,
&time_donated,
rig,
xp_alive
xp_alive,
state_xvb.p2pool_buffer
).await;
})));
} else {

View file

@ -461,7 +461,6 @@ pub const XVB_NODE_RPC: &str = "18089";
pub const XVB_URL_RULES: &str = "https://xmrvsbeast.com/p2pool/rules.html";
// buffer in percentage of HR to have plus the requirement.
pub const XVB_SIDE_MARGIN_1H: f32 = 1.20;
pub const XVB_BUFFER: f32 = 1.05;
pub const XVB_TIME_ALGO: u32 = 600;
pub const XVB_TOKEN_LEN: usize = 9;
pub const XVB_HERO_SELECT: &str =