tFixed bug where switching servers causes assert failure. - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 6dfb9e12c7bad5eb50d2b8b4a154874c6af306da (DIR) parent 3fe5ba85b2696be22339639aa79558b985b1fafb (HTM) Author: Amir Taaki <genjix@riseup.net> Date: Mon, 27 Aug 2012 04:02:15 +0200 Fixed bug where switching servers causes assert failure. Diffstat: M lib/interface.py | 8 +++++--- M lib/wallet.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) --- (DIR) diff --git a/lib/interface.py b/lib/interface.py t@@ -313,7 +313,7 @@ class WalletSynchronizer(threading.Thread): self.loop = loop self.init_interface() - def init_interface(self): + def init_interface(self, servers_loaded_callback=None): try: host, port, protocol = self.wallet.server.split(':') port = int(port) t@@ -332,6 +332,7 @@ class WalletSynchronizer(threading.Thread): InterfaceClass = TcpStratumInterface self.interface = InterfaceClass(host, port, self.wallet.debug_server) + self.interface.servers_loaded_callback = servers_loaded_callback self.wallet.interface = self.interface t@@ -363,7 +364,7 @@ class WalletSynchronizer(threading.Thread): if ports and version: servers.append( (host, ports) ) self.interface.servers = servers - assert self.interface.servers_loaded_callback + assert self.interface.servers_loaded_callback is not None self.interface.servers_loaded_callback() elif method == 'blockchain.address.subscribe': t@@ -427,7 +428,8 @@ class WalletSynchronizer(threading.Thread): self.wallet.trigger_callbacks() if self.loop: time.sleep(5) - self.init_interface() + # Server has been changed. Copy callback for new interface. + self.init_interface(self.interface.servers_loaded_callback) self.start_interface() continue else: (DIR) diff --git a/lib/wallet.py b/lib/wallet.py t@@ -350,7 +350,7 @@ class Wallet: # raise an error if the format isnt correct a,b,c = server.split(':') b = int(b) - assert c in ['t','h','n'] + assert c in ['t', 'h', 'n'] # set the server if server != self.server: self.server = server