]> git.bitcoin.ninja Git - dnsseed-rust/commitdiff
Preallocate the header maps
authorMatt Corallo <git@bluematt.me>
Tue, 21 May 2019 15:19:06 +0000 (11:19 -0400)
committerMatt Corallo <git@bluematt.me>
Tue, 21 May 2019 15:19:06 +0000 (11:19 -0400)
src/main.rs

index e040b95e7913ff1c51c7839a2d155a78c9490931..be4c8fcfd07d32b52dd0f506f9b9f905a39ed914 100644 (file)
@@ -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)))) };