projects
/
dnsseed-rust
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2ff004b
)
Implement WasGood timeout
author
Matt Corallo
<git@bluematt.me>
Mon, 20 May 2019 23:02:48 +0000
(19:02 -0400)
committer
Matt Corallo
<git@bluematt.me>
Mon, 20 May 2019 23:02:48 +0000
(19:02 -0400)
src/datastore.rs
patch
|
blob
|
history
diff --git
a/src/datastore.rs
b/src/datastore.rs
index 309d361fbb70517daf5159ae7d6c5958bfcc9c2c..7b12adb76b845e24db57cddb209e3d299a70859f 100644
(file)
--- a/
src/datastore.rs
+++ b/
src/datastore.rs
@@
-46,9
+46,10
@@
pub enum RegexSetting {
}
struct Node {
}
struct Node {
- state: AddressState,
- last_services: u64,
last_update: Instant,
last_update: Instant,
+ last_good: Instant, // Ignored unless state is Good or WasGood
+ last_services: u64,
+ state: AddressState,
}
struct Nodes {
}
struct Nodes {
@@
-200,6
+201,7
@@
impl Store {
},
last_services,
last_update: Instant::now(),
},
last_services,
last_update: Instant::now(),
+ last_good: Instant::now(),
};
if node.state == AddressState::Good {
for i in 0..64 {
};
if node.state == AddressState::Good {
for i in 0..64 {
@@
-256,6
+258,7
@@
impl Store {
state: AddressState::Untested,
last_services: 0,
last_update: cur_time,
state: AddressState::Untested,
last_services: 0,
last_update: cur_time,
+ last_good: Instant::now(),
});
nodes.state_next_scan.get_mut(&AddressState::Untested).unwrap().push((cur_time, socketaddr));
},
});
nodes.state_next_scan.get_mut(&AddressState::Untested).unwrap().push((cur_time, socketaddr));
},
@@
-272,7
+275,9
@@
impl Store {
let nodes = nodes_lock.borrow_mut();
let state_ref = nodes.nodes_to_state.get_mut(&addr).unwrap();
state_ref.last_update = Instant::now();
let nodes = nodes_lock.borrow_mut();
let state_ref = nodes.nodes_to_state.get_mut(&addr).unwrap();
state_ref.last_update = Instant::now();
- if state_ref.state == AddressState::Good && state != AddressState::Good {
+ if (state_ref.state == AddressState::Good || state_ref.state == AddressState::WasGood)
+ && state != AddressState::Good
+ && state_ref.last_good >= state_ref.last_update + Duration::from_secs(self.get_u64(U64Setting::WasGoodTimeout)) {
state_ref.state = AddressState::WasGood;
for i in 0..64 {
if state_ref.last_services & (1 << i) != 0 {
state_ref.state = AddressState::WasGood;
for i in 0..64 {
if state_ref.last_services & (1 << i) != 0 {
@@
-292,6
+297,7
@@
impl Store {
}
}
state_ref.last_services = services;
}
}
state_ref.last_services = services;
+ state_ref.last_good = state_ref.last_update;
}
nodes.state_next_scan.get_mut(&state).unwrap().push((state_ref.last_update, addr));
}
}
nodes.state_next_scan.get_mut(&state).unwrap().push((state_ref.last_update, addr));
}