From: Matt Corallo Date: Tue, 21 May 2019 15:19:06 +0000 (-0400) Subject: Preallocate the header maps X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=07be8b3a993efca917fd415b8d97200d1eedb2e6;p=dnsseed-rust Preallocate the header maps --- diff --git a/src/main.rs b/src/main.rs index e040b95..be4c8fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -310,8 +310,8 @@ fn main() { return; } - unsafe { HEADER_MAP = Some(Box::new(Mutex::new(HashMap::new()))) }; - unsafe { HEIGHT_MAP = Some(Box::new(Mutex::new(HashMap::new()))) }; + unsafe { HEADER_MAP = Some(Box::new(Mutex::new(HashMap::with_capacity(600000)))) }; + unsafe { HEIGHT_MAP = Some(Box::new(Mutex::new(HashMap::with_capacity(600000)))) }; unsafe { HEADER_MAP.as_ref().unwrap() }.lock().unwrap().insert(genesis_block(Network::Bitcoin).bitcoin_hash(), 0); unsafe { HEIGHT_MAP.as_ref().unwrap() }.lock().unwrap().insert(0, genesis_block(Network::Bitcoin).bitcoin_hash()); unsafe { HIGHEST_HEADER = Some(Box::new(Mutex::new((genesis_block(Network::Bitcoin).bitcoin_hash(), 0)))) };