From: Matt Corallo Date: Tue, 21 May 2019 14:35:18 +0000 (-0400) Subject: Dont ever run two scan threads X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=012e5d2f9c9c9acacc63bf89a2727c72a1863167;p=dnsseed-rust Dont ever run two scan threads --- diff --git a/src/main.rs b/src/main.rs index ae38a5b..3086731 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,7 @@ static mut HEIGHT_MAP: Option>>> = None; static mut DATA_STORE: Option> = None; static mut PRINTER: Option> = None; pub static START_SHUTDOWN: AtomicBool = AtomicBool::new(false); +static SCANNING: AtomicBool = AtomicBool::new(false); struct PeerState { request: (u64, sha256d::Hash), @@ -263,7 +264,9 @@ fn make_trusted_conn(trusted_sockaddr: SocketAddr) { = (headers.last().unwrap().bitcoin_hash(), top_height); printer.set_stat(printer::Stat::HeaderCount(top_height)); if top_height >= starting_height as u64 { - scan_net(); + if !SCANNING.swap(true, Ordering::SeqCst) { + scan_net(); + } } } else { // Wat? Lets start again...