p2pool: refine ping auto_select

This commit is contained in:
hinto-janaiyo 2022-11-21 20:10:47 -05:00
parent 0b8d65ae6e
commit 88e172a2e3
No known key found for this signature in database
GPG key ID: B1C5A64B80691E45
2 changed files with 6 additions and 5 deletions

View file

@ -197,7 +197,11 @@ impl Ping {
std::thread::spawn(move|| {
info!("Spawning ping thread...");
match Self::ping(ping.clone(), og) {
Ok(_) => info!("Ping ... OK"),
Ok(_) => {
info!("Ping ... OK");
ping.lock().unwrap().pinged = true;
ping.lock().unwrap().auto_selected = false;
},
Err(err) => {
error!("Ping ... FAIL ... {}", err);
ping.lock().unwrap().pinged = false;
@ -274,9 +278,6 @@ impl Ping {
ping.nodes = node_vec;
ping.prog = 100.0;
ping.msg = info;
ping.pinging = false;
ping.pinged = true;
ping.auto_selected = false;
drop(ping);
Ok(())
}

View file

@ -92,7 +92,7 @@ impl P2pool {
if self.auto_select {
let mut ping = ping.lock().unwrap();
// If we haven't auto_selected yet, auto-select and turn it off
if ping.auto_selected == false {
if ping.pinged && ping.auto_selected == false {
self.node = ping.fastest;
ping.auto_selected = true;
}