diff --git a/src/helper/xvb/mod.rs b/src/helper/xvb/mod.rs index 6459591..afef71b 100644 --- a/src/helper/xvb/mod.rs +++ b/src/helper/xvb/mod.rs @@ -211,6 +211,8 @@ impl Helper { // check if first loop the state of Xmrig-Proxy if first_loop { xp_alive = lock!(process_xp).state == ProcessState::Alive; + msg_retry_done = false; + *lock!(retry) = false; } // verify if p2pool and xmrig are running, else XvB must be reloaded with another token/address to start verifying the other process. if check_state_outcauses_xvb( @@ -234,11 +236,11 @@ impl Helper { { continue; } - // check signal debug!("XvB | check signal"); if signal_interrupt( process, + if xp_alive { process_xp } else { process_xmrig }, start.into(), &client, pub_api, @@ -317,7 +319,8 @@ impl Helper { } } let hashrate = current_controllable_hr(xp_alive, &gui_api_xp, &gui_api_xmrig); - if (first_loop || *lock!(retry)|| is_algo_finished) && hashrate > 0.0 && lock!(process).state == ProcessState::Alive + let difficulty_data_is_ready = lock!(gui_api_p2pool).p2pool_difficulty_u64 > 100_000; + if (first_loop || *lock!(retry)|| is_algo_finished) && hashrate > 0.0 && lock!(process).state == ProcessState::Alive && difficulty_data_is_ready { // if algo was started, it must not retry next loop. *lock!(retry) = false; @@ -352,7 +355,7 @@ impl Helper { } else { // if xmrig is still at 0 HR but is alive and algorithm is skipped, recheck first 10s of xmrig inside algorithm next time (in one minute). Don't check if algo failed to start because state was not alive after getting private stats. - if current_controllable_hr(xp_alive, &gui_api_xp, &gui_api_xmrig) == 0.0 && lock!(process).state == ProcessState::Alive { + if (hashrate == 0.0 || !difficulty_data_is_ready) && lock!(process).state == ProcessState::Alive { *lock!(retry) = true } } @@ -369,9 +372,9 @@ impl Helper { // show this message only once before the start of algo if *lock!(retry) && !msg_retry_done { let msg = if xp_alive { - "Algorithm is waiting for 1 minute average HR of XMRig-Proxy" + "Algorithm is waiting for 1 minute average HR of XMRig-Proxy or p2pool data" } else { - "Algorithm is waiting for 10 seconds average HR of XMRig." + "Algorithm is waiting for 10 seconds average HR of XMRig or p2pool data" }; output_console(&mut lock!(gui_api).output, msg, ProcessName::Xvb); msg_retry_done = true; @@ -491,7 +494,7 @@ async fn check_conditions_for_start( output_console(&mut lock!(gui_api).output, msg, ProcessName::Xvb); ProcessState::Syncing } else if lock!(process_xmrig).state != ProcessState::Alive - || lock!(process_xp).state != ProcessState::Alive + && lock!(process_xp).state != ProcessState::Alive { // send to console: xmrig process is not running warn!("Xvb | Start ... Partially failed because Xmrig or Xmrig-Proxy instance is not running."); @@ -677,6 +680,7 @@ async fn check_state_outcauses_xvb( #[allow(clippy::too_many_arguments)] fn signal_interrupt( process: &Arc>, + process_xrig: &Arc>, start: Instant, client: &Client, pub_api: &Arc>, @@ -745,13 +749,12 @@ fn signal_interrupt( // if both XvB nodes fail after checking, process will be partially stopped and a new spawn will verify if nodes are again online and so will continue the process completely if that's the case. // if P2pool, the process has to stop the algo and continue partially. The process will continue completely if the confitions are met again. // if XvB was not alive, then if it is for XvB nodes, it will check and update preferred node and set XMRig to P2pool if that's not the case. - // if XvB was not alive and update was for P2pool, XvB must ignore. XMRig will stop sending signals because current node will be none. - let was_alive = lock!(process).state != ProcessState::Alive; + let was_alive = lock!(process).state == ProcessState::Alive; // so it won't execute another signal of update nodes if it is already doing it. lock!(process).state = ProcessState::Waiting; lock!(process).signal = ProcessSignal::None; spawn( - enc!((node, process, client, gui_api, pub_api, was_alive, address, token_xmrig, gui_api_xmrig, gui_api_xp) async move { + enc!((node, process, client, gui_api, pub_api, was_alive, address, token_xmrig, gui_api_xmrig, gui_api_xp,process_xrig) async move { warn!("in spawn of UpdateNodes"); match node { XvbNode::NorthAmerica|XvbNode::Europe if was_alive => { @@ -778,7 +781,8 @@ fn signal_interrupt( // Probably a start. We don't consider XMRig using XvB nodes without algo. // can update xmrig and check status of state in the same time. // Need to set XMRig to P2Pool if it wasn't. XMRig should have populated this value at his start. - + // but if xmrig didn't start, don't update it. + if lock!(process_xrig).state == ProcessState::Alive { if lock!(gui_api).current_node != Some(XvbNode::P2pool) { spawn(enc!((client, token_xmrig, address, gui_api_xmrig, gui_api_xp, gui_api) async move{ let url_api = api_url_xmrig(xp_alive, true); @@ -814,6 +818,7 @@ fn signal_interrupt( } } ));} + } }, _ => {} } } ),