From 88e172a2e3d24ef1816c6026663310b8833941ce Mon Sep 17 00:00:00 2001 From: hinto-janaiyo Date: Mon, 21 Nov 2022 20:10:47 -0500 Subject: [PATCH] p2pool: refine ping auto_select --- src/node.rs | 9 +++++---- src/p2pool.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/node.rs b/src/node.rs index 460c689..5dae0a2 100644 --- a/src/node.rs +++ b/src/node.rs @@ -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(()) } diff --git a/src/p2pool.rs b/src/p2pool.rs index 22391ac..ed26836 100644 --- a/src/p2pool.rs +++ b/src/p2pool.rs @@ -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; }