interface: fix off-by-one in request_chunk

was harmless; usually we just downloaded an extra individual header after the chunk
This commit is contained in:
SomberNight 2018-09-16 09:01:53 +02:00
parent 1d711eeadc
commit 9c919e6478
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -326,7 +326,7 @@ class Interface(PrintError):
self.print_error("requesting chunk from height {}".format(height)) self.print_error("requesting chunk from height {}".format(height))
size = 2016 size = 2016
if tip is not None: if tip is not None:
size = min(size, tip - index * 2016) size = min(size, tip - index * 2016 + 1)
size = max(size, 0) size = max(size, 0)
try: try:
self._requested_chunks.add(index) self._requested_chunks.add(index)
@ -411,8 +411,7 @@ class Interface(PrintError):
continue continue
self.network.notify('updated') self.network.notify('updated')
height = (height // 2016 * 2016) + num_headers height = (height // 2016 * 2016) + num_headers
if height > next_height: assert height <= next_height+1, (height, self.tip)
assert False, (height, self.tip)
last = 'catchup' last = 'catchup'
else: else:
last, height = await self.step(height) last, height = await self.step(height)