fixes, resend_subscriptions
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user