URI: 
       tfixes, resend_subscriptions - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 77871b97af2a7f9fceccf3bf2a62652414e6ff51
   DIR parent 79645e9b37702010684ae3c712183826786f0f50
  HTML Author: thomasv <thomasv@gitorious>
       Date:   Tue, 10 Sep 2013 19:59:58 +0200
       
       fixes, resend_subscriptions
       
       Diffstat:
         M gui/network_dialog.py               |      14 +++++++++++---
         M lib/blockchain.py                   |       4 ++--
         M lib/interface.py                    |       2 +-
         M lib/network.py                      |      15 ++++++++++++---
       
       4 files changed, 26 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/gui/network_dialog.py b/gui/network_dialog.py
       t@@ -44,10 +44,18 @@ class NetworkDialog(QDialog):
                self.protocol = None
        
                if parent:
       -            if interface.is_connected:
       -                status = _("Connected to")+" %s"%(interface.host) + "\n%d "%(network.blockchain.height)+_("blocks")
       +            n = len(network.interfaces)
       +            if n:
       +                status = _("Connected to %d servers")%n + ", %d "%(network.blockchain.height) + _("blocks")
                    else:
                        status = _("Not connected")
       +
       +            if interface.is_connected:
       +                status += "\n" + _("History server:") + " %s"%(interface.host) 
       +            else:
       +                status += "\n" + _("History server is disconnected")
       +                
       +
                    server = interface.server
                else:
                    import random
       t@@ -229,6 +237,6 @@ class NetworkDialog(QDialog):
        
                self.config.set_key("proxy", proxy, True)
                self.config.set_key("server", server, True)
       -        self.interface.set_server(server, proxy)
       +        self.network.set_server(server, proxy)
                self.config.set_key('auto_cycle', self.autocycle_cb.isChecked(), True)
                return True
   DIR diff --git a/lib/blockchain.py b/lib/blockchain.py
       t@@ -93,8 +93,8 @@ class Blockchain(threading.Thread):
                        self.network.trigger_callback('updated')
        
                    h = self.servers_height.get(self.network.interface.server)
       -            if h is not None and h < height:
       -                print "server is lagging", height - i.network.interface.height
       +            if h is not None and h < height - 1:
       +                print "server is lagging", height, h
                        self.network.interface.stop()
        
        
   DIR diff --git a/lib/interface.py b/lib/interface.py
       t@@ -129,7 +129,7 @@ class Interface(threading.Thread):
                        with self.lock: 
                            method, params, channel = self.unanswered_requests.pop(msg_id)
                        response_queue = self.responses[channel]
       -                response_queue.put({'method':method, 'params':params, 'error':error, 'id':msg_id})
       +                response_queue.put((self,{'method':method, 'params':params, 'error':error, 'id':msg_id}))
        
                    return
        
   DIR diff --git a/lib/network.py b/lib/network.py
       t@@ -78,6 +78,15 @@ class Network(threading.Thread):
                    return self.interface.is_connected
        
        
       +    def set_server(self, server, proxy):
       +        subscriptions = self.interface.subscriptions
       +        self.default_server = server
       +        self.start_interface(server)
       +        self.interface = self.interfaces[server]
       +        self.resend_subscriptions(subscriptions)
       +        self.trigger_callback('disconnecting') # for actively disconnecting
       +
       +
            def run(self):
                self.blockchain.start()
        
       t@@ -122,10 +131,10 @@ class Network(threading.Thread):
                with self.lock: return self.running
        
        
       -    def resend_subscriptions(self):
       -        for channel, messages in self.subscriptions.items():
       +    def resend_subscriptions(self, subscriptions):
       +        for channel, messages in subscriptions.items():
                    if messages:
       -                self.send(messages, channel)
       +                self.interface.send(messages, channel)