feat: add more log about calculation of HR by algo

This commit is contained in:
Cyrix126 2024-05-31 17:38:32 +02:00
parent 41dd12f092
commit 0eb863e3d8
2 changed files with 14 additions and 6 deletions

View file

@ -31,17 +31,19 @@ pub(crate) fn calcul_donated_time(
let p2pool_ehr = lock!(gui_api_p2pool).sidechain_ehr; let p2pool_ehr = lock!(gui_api_p2pool).sidechain_ehr;
// what if ehr stay still for the next ten minutes ? mHR will augment every ten minutes because it thinks that oHR is decreasing. // what if ehr stay still for the next ten minutes ? mHR will augment every ten minutes because it thinks that oHR is decreasing.
// //
let p2pool_ohr = p2pool_ehr let avg_hr = calc_last_hour_avg_hash_rate(&lock!(gui_api_xvb).p2pool_sent_last_hour_samples);
- calc_last_hour_avg_hash_rate(&lock!(gui_api_xvb).p2pool_sent_last_hour_samples); let p2pool_ohr = p2pool_ehr - avg_hr;
info!("XvB Process | p2pool sidechain HR - last hour average HR = estimated outside HR\n{p2pool_ehr} - {avg_hr} = {p2pool_ohr}");
let mut min_hr = minimum_hashrate_share( let mut min_hr = minimum_hashrate_share(
lock!(gui_api_p2pool).p2pool_difficulty_u64, lock!(gui_api_p2pool).p2pool_difficulty_u64,
state_p2pool.mini, state_p2pool.mini,
p2pool_ohr, p2pool_ohr,
); );
if min_hr.is_sign_negative() { if min_hr.is_sign_negative() {
info!("XvB Process | if minimum HR is negative, it is 0.");
min_hr = 0.0; min_hr = 0.0;
} }
debug!("Xvb Process | hr {}, min_hr: {} ", lhr, min_hr); info!("Xvb Process | hr {}, min_hr: {} ", lhr, min_hr);
// numbers are divided by a thousands to print kH/s and not H/s // numbers are divided by a thousands to print kH/s and not H/s
let msg_lhr = format!( let msg_lhr = format!(
"{} kH/s local HR from Xmrig", "{} kH/s local HR from Xmrig",
@ -65,7 +67,7 @@ pub(crate) fn calcul_donated_time(
// if not hero option // if not hero option
if !lock!(gui_api_xvb).stats_priv.runtime_hero_mode { if !lock!(gui_api_xvb).stats_priv.runtime_hero_mode {
let xvb_chr = lock!(gui_api_xvb).stats_priv.donor_1hr_avg * 1000.0; let xvb_chr = lock!(gui_api_xvb).stats_priv.donor_1hr_avg * 1000.0;
info!("current HR on XVB (last hour): {xvb_chr}"); info!("current HR on XvB (last hour): {xvb_chr}");
let shr = calc_last_hour_avg_hash_rate(&lock!(gui_api_xvb).xvb_sent_last_hour_samples); let shr = calc_last_hour_avg_hash_rate(&lock!(gui_api_xvb).xvb_sent_last_hour_samples);
// calculate how much time needed to be spared to be in most round type minimum HR + buffer // calculate how much time needed to be spared to be in most round type minimum HR + buffer
spared_time = minimum_time_for_highest_accessible_round(spared_time, lhr, xvb_chr, shr); spared_time = minimum_time_for_highest_accessible_round(spared_time, lhr, xvb_chr, shr);
@ -82,14 +84,19 @@ fn minimum_hashrate_share(difficulty: u64, mini: bool, ohr: f32) -> f32 {
} else { } else {
BLOCK_PPLNS_WINDOW_MAIN BLOCK_PPLNS_WINDOW_MAIN
}; };
((difficulty / (pws * SECOND_PER_BLOCK_P2POOL)) as f32 * XVB_BUFFER) - ohr let minimum_hr = ((difficulty / (pws * SECOND_PER_BLOCK_P2POOL)) as f32 * XVB_BUFFER) - ohr;
info!("XvB Process | (difficulty / (window pplns blocks * seconds per p2pool block) * BUFFER) - outside HR\n({difficulty} / ({pws} * {SECOND_PER_BLOCK_P2POOL}) * {XVB_BUFFER}) - {ohr}");
minimum_hr
} }
fn time_that_could_be_spared(hr: f32, min_hr: f32) -> u32 { fn time_that_could_be_spared(hr: f32, min_hr: f32) -> u32 {
// percent of time minimum // percent of time minimum
let minimum_time_required_on_p2pool = XVB_TIME_ALGO as f32 / (hr / min_hr); let minimum_time_required_on_p2pool = XVB_TIME_ALGO as f32 / (hr / min_hr);
info!("XvB Process | Time of algo / local hashrate / minimum hashrate = minimum time required on p2pool\n{XVB_TIME_ALGO} / ({hr} / {min_hr}) = {minimum_time_required_on_p2pool}");
let spared_time = XVB_TIME_ALGO as f32 - minimum_time_required_on_p2pool; let spared_time = XVB_TIME_ALGO as f32 - minimum_time_required_on_p2pool;
info!("XvB Process | Time of algo - minimum time required on p2pool = time that can be spared.\n{XVB_TIME_ALGO} - {minimum_time_required_on_p2pool}");
// if less than 6 seconds, XMRig could hardly have the time to mine anything. // if less than 6 seconds, XMRig could hardly have the time to mine anything.
if spared_time >= 6.0 { if spared_time >= 6.0 {
info!("XvB Process | sparted time is equal or less than 6 seconds, so everything goes to p2pool.");
return spared_time as u32; return spared_time as u32;
} }
0 0

View file

@ -619,6 +619,7 @@ fn signal_interrupt(
} }
ProcessSignal::UpdateNodes(node) => { ProcessSignal::UpdateNodes(node) => {
if lock!(process).state != ProcessState::Waiting { if lock!(process).state != ProcessState::Waiting {
warn!("received the UpdateNode signal");
let token_xmrig = state_xmrig.token.clone(); let token_xmrig = state_xmrig.token.clone();
let rig = state_xmrig.rig.clone(); let rig = state_xmrig.rig.clone();
let address = state_p2pool.address.clone(); let address = state_p2pool.address.clone();
@ -641,7 +642,7 @@ fn signal_interrupt(
if lock!(process).state == ProcessState::OfflineNodesAll { if lock!(process).state == ProcessState::OfflineNodesAll {
// No available nodes, so launch a process to verify periodicly. // No available nodes, so launch a process to verify periodicly.
sleep(Duration::from_secs(10)).await; sleep(Duration::from_secs(10)).await;
info!("node fail, set spawn that will retry nodes and update state."); warn!("node fail, set spawn that will retry nodes and update state.");
while lock!(process).state == ProcessState::OfflineNodesAll { while lock!(process).state == ProcessState::OfflineNodesAll {
// this spawn will stay alive until nodes are joignable or XvB process is stopped or failed. // this spawn will stay alive until nodes are joignable or XvB process is stopped or failed.
XvbNode::update_fastest_node(&client, &pub_api, &gui_api, &process).await; XvbNode::update_fastest_node(&client, &pub_api, &gui_api, &process).await;