From 07be8b3a993efca917fd415b8d97200d1eedb2e6 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 21 May 2019 11:19:06 -0400 Subject: [PATCH] Preallocate the header maps --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)))) }; -- 2.39.5