fix issue with starting requested block number was not included itself

This commit is contained in:
Nikolay Volf 2016-02-24 14:36:41 +03:00
parent e519e162df
commit d51942e59d

View File

@ -927,13 +927,13 @@ impl ChainSync {
if reverse { if reverse {
number = min(last, number); number = min(last, number);
} else { } else {
number = max(1, number); number = max(0, number);
} }
let max_count = min(MAX_HEADERS_TO_SEND, max_headers); let max_count = min(MAX_HEADERS_TO_SEND, max_headers);
let mut count = 0; let mut count = 0;
let mut data = Bytes::new(); let mut data = Bytes::new();
let inc = (skip + 1) as BlockNumber; let inc = (skip + 1) as BlockNumber;
while number <= last && number > 0 && count < max_count { while number <= last && number >= 0 && count < max_count {
if let Some(mut hdr) = io.chain().block_header(BlockId::Number(number)) { if let Some(mut hdr) = io.chain().block_header(BlockId::Number(number)) {
data.append(&mut hdr); data.append(&mut hdr);
count += 1; count += 1;