electrum

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

commit 6dfb9e12c7bad5eb50d2b8b4a154874c6af306da
parent 3fe5ba85b2696be22339639aa79558b985b1fafb
Author: Amir Taaki <genjix@riseup.net>
Date:   Mon, 27 Aug 2012 04:02:15 +0200

Fixed bug where switching servers causes assert failure.

Diffstat:
Mlib/interface.py | 8+++++---
Mlib/wallet.py | 2+-
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -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) @@ -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 @@ -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': @@ -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: diff --git a/lib/wallet.py b/lib/wallet.py @@ -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