From 012e5d2f9c9c9acacc63bf89a2727c72a1863167 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 21 May 2019 10:35:18 -0400 Subject: [PATCH] Dont ever run two scan threads --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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... -- 2.39.5