projects
/
dnsseed-rust
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fa44fd6
)
Fix split point calculation
author
Matt Corallo
<git@bluematt.me>
Sun, 2 Jun 2019 14:41:11 +0000
(10:41 -0400)
committer
Matt Corallo
<git@bluematt.me>
Sun, 2 Jun 2019 14:41:11 +0000
(10:41 -0400)
src/datastore.rs
patch
|
blob
|
history
diff --git
a/src/datastore.rs
b/src/datastore.rs
index 827726e9aae9dae21a1d8c71840c7e8dc2325881..1a3d7c94024ce75dd1cd78dabe13dc29eadcf942 100644
(file)
--- a/
src/datastore.rs
+++ b/
src/datastore.rs
@@
-496,7
+496,7
@@
impl Store {
let mut nodes = self.nodes.write().unwrap();
for (idx, state_nodes) in nodes.state_next_scan.iter_mut().enumerate() {
let cmp_time = cur_time - Duration::from_secs(self.get_u64(U64Setting::RescanInterval(AddressState::from_num(idx as u8).unwrap())));
let mut nodes = self.nodes.write().unwrap();
for (idx, state_nodes) in nodes.state_next_scan.iter_mut().enumerate() {
let cmp_time = cur_time - Duration::from_secs(self.get_u64(U64Setting::RescanInterval(AddressState::from_num(idx as u8).unwrap())));
- let split_point = cmp::min(cmp::min(results - res.len(),
results - (per_bucket_results * (AddressState::get_count() as usize - idx)
)),
+ let split_point = cmp::min(cmp::min(results - res.len(),
(per_bucket_results * (idx + 1)) - res.len(
)),
state_nodes.binary_search_by(|a| a.0.cmp(&cmp_time)).unwrap_or_else(|idx| idx));
let mut new_nodes = state_nodes.split_off(split_point);
mem::swap(&mut new_nodes, state_nodes);
state_nodes.binary_search_by(|a| a.0.cmp(&cmp_time)).unwrap_or_else(|idx| idx));
let mut new_nodes = state_nodes.split_off(split_point);
mem::swap(&mut new_nodes, state_nodes);