Fixed one extra block/header being requested
This commit is contained in:
parent
64b15cdbc0
commit
f4d8070bda
@ -607,7 +607,7 @@ impl ChainSync {
|
|||||||
|
|
||||||
if self.have_common_block && !self.headers.is_empty() && self.headers.range_iter().next().unwrap().0 == self.current_base_block() + 1 {
|
if self.have_common_block && !self.headers.is_empty() && self.headers.range_iter().next().unwrap().0 == self.current_base_block() + 1 {
|
||||||
for (start, ref items) in self.headers.range_iter() {
|
for (start, ref items) in self.headers.range_iter() {
|
||||||
if needed_bodies.len() > MAX_BODIES_TO_REQUEST {
|
if needed_bodies.len() >= MAX_BODIES_TO_REQUEST {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let mut index: BlockNumber = 0;
|
let mut index: BlockNumber = 0;
|
||||||
@ -654,7 +654,7 @@ impl ChainSync {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut block = prev;
|
let mut block = prev;
|
||||||
while block < next && headers.len() <= MAX_HEADERS_TO_REQUEST {
|
while block < next && headers.len() < MAX_HEADERS_TO_REQUEST {
|
||||||
if !self.downloading_headers.contains(&(block as BlockNumber)) {
|
if !self.downloading_headers.contains(&(block as BlockNumber)) {
|
||||||
headers.push(block as BlockNumber);
|
headers.push(block as BlockNumber);
|
||||||
self.downloading_headers.insert(block as BlockNumber);
|
self.downloading_headers.insert(block as BlockNumber);
|
||||||
@ -1478,4 +1478,4 @@ mod tests {
|
|||||||
let result = sync.on_peer_new_block(&mut io, 0, &UntrustedRlp::new(&data));
|
let result = sync.on_peer_new_block(&mut io, 0, &UntrustedRlp::new(&data));
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user