mod timeout_stream;
mod datastore;
-use std::env;
+use std::{cmp, env};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{Ordering, AtomicBool};
let store = unsafe { DATA_STORE.as_ref().unwrap() };
let mut scan_nodes = store.get_next_scan_nodes();
let per_iter_time = Duration::from_millis(1000 / store.get_u64(U64Setting::ConnsPerSec));
- let mut iter_time = Instant::now();
+ let start_time = Instant::now();
+ let mut iter_time = start_time;
for node in scan_nodes.drain(..) {
scan_node(iter_time, node);
iter_time += per_iter_time;
}
- Delay::new(iter_time).then(|_| {
+ Delay::new(cmp::max(iter_time, start_time + Duration::from_secs(15))).then(|_| {
let store = unsafe { DATA_STORE.as_ref().unwrap() };
store.save_data().then(|_| {
if !START_SHUTDOWN.load(Ordering::Relaxed) {
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)))) };