Merge branch 'dev' of github.com:mostafaei2002/gupaxx into dev

This commit is contained in:
mostafaei2002 2024-07-24 22:48:00 +03:30
commit b682813ab6
4 changed files with 33 additions and 19 deletions

View file

@ -163,7 +163,7 @@ impl Helper {
let path = path.to_path_buf();
// This thread lives to wait, start p2pool then die.
thread::spawn(move || {
while lock2!(helper, p2pool).is_alive() {
while lock2!(helper, p2pool).state != ProcessState::Waiting {
warn!("P2Pool | Want to restart but process is still alive, waiting...");
sleep!(1000);
}
@ -545,8 +545,11 @@ impl Helper {
// If more than 1 minute has passed, read the other API files.
let last_p2pool_request_expired =
last_p2pool_request.elapsed() >= Duration::from_secs(60);
if last_p2pool_request_expired {
// need to reload fast to get the first right values after syncing.
if last_p2pool_request_expired
|| (!lock!(pub_api).p2pool_difficulty_u64 > 100_000
&& lock!(process).state == ProcessState::Alive)
{
debug!("P2Pool Watchdog | Attempting [network] & [pool] API file read");
if let (Ok(network_api), Ok(pool_api)) = (
Self::path_to_string(&api_path_network, ProcessName::P2pool),

View file

@ -70,7 +70,11 @@ impl Helper {
// updating current node to None, will stop sending signal of FailedNode until new node is set
// send signal to update node.
warn!("XMRig PTY Parse | node is offline, sending signal to update nodes.");
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(current_node);
// update nodes only if we were not mining on p2pool.
// if xmrig stop, xvb will react in any case.
if current_node != XvbNode::P2pool {
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(current_node);
}
lock!(pub_api_xvb).current_node = None;
}
}

View file

@ -72,7 +72,9 @@ impl Helper {
warn!(
"XMRig-Proxy PTY Parse | node is offline, sending signal to update nodes."
);
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(current_node);
if current_node != XvbNode::P2pool {
lock!(process_xvb).signal = ProcessSignal::UpdateNodes(current_node);
}
lock!(pub_api_xvb).current_node = None;
}
}
@ -212,7 +214,7 @@ impl Helper {
state_xmrig: &Xmrig,
path: &Path,
) {
info!("XMRig | Attempting to restart...");
info!("XMRig-Proxy | Attempting to restart...");
lock2!(helper, xmrig_proxy).state = ProcessState::Middle;
lock2!(helper, xmrig_proxy).signal = ProcessSignal::Restart;
@ -227,10 +229,10 @@ impl Helper {
sleep!(1000);
}
// Ok, process is not alive, start the new one!
info!("XMRig_proxy | Old process seems dead, starting new one!");
info!("XMRig-Proxy | Old process seems dead, starting new one!");
Self::start_xp(&helper, &state, &state_xmrig, &path);
});
info!("XMRig | Restart ... OK");
info!("XMRig-Proxy | Restart ... OK");
}
pub fn start_xp(
helper: &Arc<Mutex<Self>>,
@ -354,7 +356,7 @@ impl Helper {
if let Err(e) = writeln!(stdin, "c") {
error!("P2Pool Watchdog | STDIN error: {}", e);
}
info!("XMRig | Entering watchdog mode... woof!");
info!("XMRig-Proxy | Entering watchdog mode... woof!");
loop {
let now = Instant::now();
debug!("XMRig-Proxy Watchdog | ----------- Start of loop -----------");

View file

@ -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<Mutex<Process>>,
process_xrig: &Arc<Mutex<Process>>,
start: Instant,
client: &Client,
pub_api: &Arc<Mutex<PubXvbApi>>,
@ -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(
}
}
));}
}
},
_ => {}
} } ),