electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 3fc9326c4374af64eb9c294aa754df86adb22ba8
parent da23e71db1f270c26ffbb217ca29f3df6649a315
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 16 Sep 2018 07:35:11 +0200

interface: try hard not to infinite loop while getting headers

Diffstat:
Melectrum/interface.py | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/electrum/interface.py b/electrum/interface.py @@ -400,6 +400,7 @@ class Interface(PrintError): next_height = self.tip last = None while last is None or height <= next_height: + prev_last, prev_height = last, height if next_height > height + 10: could_connect, num_headers = await self.request_chunk(height, next_height) if not could_connect: @@ -414,6 +415,7 @@ class Interface(PrintError): last = 'catchup' else: last, height = await self.step(height) + assert (prev_last, prev_height) != (last, height), 'had to prevent infinite loop in interface.sync_until' return last, height async def step(self, height, header=None): @@ -422,7 +424,7 @@ class Interface(PrintError): if header is None: header = await self.get_block_header(height, 'catchup') chain = self.blockchain.check_header(header) if 'mock' not in header else header['mock']['check'](header) - if chain: return 'catchup', height + if chain: return 'catchup', height+1 can_connect = blockchain.can_connect(header) if 'mock' not in header else header['mock']['connect'](height) if not can_connect: