From: Matt Corallo Date: Thu, 23 May 2019 00:52:21 +0000 (-0400) Subject: Fix manual scan X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=dnsseed-rust;a=commitdiff_plain;h=3c3d0fa794fe8d648497570103888f59f4d3f6cf Fix manual scan --- diff --git a/src/datastore.rs b/src/datastore.rs index 26ed96b..8202ce5 100644 --- a/src/datastore.rs +++ b/src/datastore.rs @@ -303,7 +303,7 @@ impl Store { state: AddressState::Untested, last_services: 0, last_update: cur_time, - last_good: Instant::now(), + last_good: cur_time, }); nodes.state_next_scan.get_mut(&AddressState::Untested).unwrap().push((cur_time, addr)); res += 1; @@ -326,9 +326,15 @@ impl Store { pub fn set_node_state(&self, addr: SocketAddr, state: AddressState, services: u64) -> AddressState { let mut nodes_lock = self.nodes.write().unwrap(); let nodes = nodes_lock.borrow_mut(); - let state_ref = nodes.nodes_to_state.get_mut(&addr).unwrap(); - let ret = state_ref.state; let now = Instant::now(); + + let state_ref = nodes.nodes_to_state.entry(addr).or_insert(Node { + state: AddressState::Untested, + last_services: 0, + last_update: now, + last_good: now, + }); + let ret = state_ref.state; if (state_ref.state == AddressState::Good || state_ref.state == AddressState::WasGood) && state != AddressState::Good && state_ref.last_good >= now - Duration::from_secs(self.get_u64(U64Setting::WasGoodTimeout)) {