From 14a032a0b16c498602ff63cd5482af123891f0c1 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 31 Aug 2018 16:46:03 +0200 Subject: [PATCH] disconnect from servers on exception --- electrum/interface.py | 2 ++ electrum/network.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/electrum/interface.py b/electrum/interface.py index 23119333b..7631e65fd 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -244,6 +244,8 @@ class BlockHeaderInterface(PrintError): could_connect, num_headers = await self.conn.request_chunk(self.height, next_height) self.tip = max(self.height + num_headers, self.tip) if not could_connect: + if self.height <= self.iface.network.max_checkpoint(): + raise Exception('server chain conflicts with checkpoints or genesis') last = await self.step() self.tip = max(self.height, self.tip) continue diff --git a/electrum/network.py b/electrum/network.py index 0436359ce..58ad60692 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -809,14 +809,16 @@ class Network(PrintError): asyncio.get_event_loop().create_task(self.new_interface(server)) remove = [] for k, i in self.interfaces.items(): - if i.fut.done(): - if i.exception: - try: - raise i.exception - except BaseException as e: - self.print_error(i.server, "errored because", str(e), str(type(e))) - else: - assert False, "interface future should not finish without exception" + if i.fut.done() and not i.exception: + assert False, "interface future should not finish without exception" + if i.exception: + if not i.fut.done(): + try: i.fut.cancel() + except Exception as e: self.print_error('exception while cancelling fut', e) + try: + raise i.exception + except BaseException as e: + self.print_error(i.server, "errored because", str(e), str(type(e))) remove.append(k) changed = False for k in remove: