From 2157eae4990ed5d80a78880409e0ebcf20ab27f5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 29 Aug 2018 18:54:25 +0200 Subject: [PATCH] fix request_chunk --- electrum/network.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/electrum/network.py b/electrum/network.py index 92378d9fa..0436359ce 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -730,15 +730,13 @@ class Network(PrintError): if session is None: session = self.interface.session index = height // 2016 size = 2016 - if tip is not None and height + 2016 >= tip: - size = tip - height - #if index * 2016 < height: - # size = height - index * 2016 + if tip is not None: + size = min(size, tip - index * 2016) + size = max(size, 0) res = await session.send_request('blockchain.block.headers', [index * 2016, size]) conn = self.blockchain().connect_chunk(index, res['hex']) if not conn: return conn, 0 - self.blockchain().save_chunk(index, bfh(res['hex'])) return conn, res['count'] @with_interface_lock