From 51ed8a998c0f80fe27a3c27c46e4ff12d875865b Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 25 Jun 2018 01:14:49 +0200 Subject: [PATCH] fix: network.interface can become None at any time --- gui/kivy/main_window.py | 5 +++-- gui/qt/network_dialog.py | 3 ++- lib/synchronizer.py | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py index 11eced5f7..0291bdd0a 100644 --- a/gui/kivy/main_window.py +++ b/gui/kivy/main_window.py @@ -639,8 +639,9 @@ class ElectrumWindow(App): chain = self.network.blockchain() self.blockchain_checkpoint = chain.get_checkpoint() self.blockchain_name = chain.get_name() - if self.network.interface: - self.server_host = self.network.interface.host + interface = self.network.interface + if interface: + self.server_host = interface.host def on_network_event(self, event, *args): Logger.info('network event: '+ event) diff --git a/gui/qt/network_dialog.py b/gui/qt/network_dialog.py index e578bb43a..f9a1f7da7 100644 --- a/gui/qt/network_dialog.py +++ b/gui/qt/network_dialog.py @@ -340,7 +340,8 @@ class NetworkChoiceLayout(object): self.server_port.setText(port) self.autoconnect_cb.setChecked(auto_connect) - host = self.network.interface.host if self.network.interface else _('None') + interface = self.network.interface + host = interface.host if interface else _('None') self.server_label.setText(host) self.set_protocol(protocol) diff --git a/lib/synchronizer.py b/lib/synchronizer.py index b792bd4d3..3a8dc0bba 100644 --- a/lib/synchronizer.py +++ b/lib/synchronizer.py @@ -126,7 +126,9 @@ class Synchronizer(ThreadJob): tx_fees = dict(filter(lambda x:x[1] is not None, tx_fees)) # Note if the server hasn't been patched to sort the items properly if hist != sorted(hist, key=lambda x:x[1]): - self.network.interface.print_error("serving improperly sorted address histories") + interface = self.network.interface + # note: we don't actually know which interface was used if it was *just* changed + if interface: interface.print_error("serving improperly sorted address histories") # Check that txids are unique if len(hashes) != len(result): self.print_error("error: server history has non-unique txids: %s"% addr)