From 866152d7203c8f11a686d073a2c3f617f9131675 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 1 Oct 2019 21:19:18 -0400 Subject: [PATCH] Fix a minor timing issue, load nodes at start with an old time --- src/datastore.rs | 3 ++- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datastore.rs b/src/datastore.rs index 2f0e9a8..0e6dea3 100644 --- a/src/datastore.rs +++ b/src/datastore.rs @@ -234,6 +234,7 @@ impl Store { } let nodes_future = File::open(store.clone() + "/nodes").and_then(|f| { + let start_time = Instant::now() - Duration::from_secs(60 * 60 * 24); let mut res = nodes_uninitd!(); let l = BufReader::new(f).lines(); for line_res in l { @@ -272,7 +273,7 @@ impl Store { } } } - res.state_next_scan[node.state.to_num() as usize].push((Instant::now(), sockaddr)); + res.state_next_scan[node.state.to_num() as usize].push((start_time, sockaddr)); res.nodes_to_state.insert(sockaddr, node); } future::ok(res) diff --git a/src/main.rs b/src/main.rs index d25020e..f9de3d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -283,7 +283,7 @@ fn scan_net() { let mut scan_nodes = store.get_next_scan_nodes(); printer.add_line(format!("Got {} addresses to scan", scan_nodes.len()), false); if !scan_nodes.is_empty() { - let per_iter_time = Duration::from_millis(datastore::SECS_PER_SCAN_RESULTS / scan_nodes.len() as u64); + let per_iter_time = Duration::from_millis(datastore::SECS_PER_SCAN_RESULTS * 1000 / scan_nodes.len() as u64); let mut iter_time = start_time; for node in scan_nodes.drain(..) { -- 2.39.5