commit cfb3aa6a12c44039e08a59e0ec5b649c0ffda053
parent 18c9c2f3696e02381fd7d2e7cc38c21896173cca
Author: ThomasV <thomasv@gitorious>
Date: Sat, 27 Oct 2012 14:15:03 +0200
move 'peers.subscribe' and 'server.version' calls into the interface
Diffstat:
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/electrum b/electrum
@@ -188,6 +188,7 @@ if __name__ == '__main__':
interface = Interface(config, True)
interface.start()
+ interface.send([('server.peers.subscribe',[])])
wallet.interface = interface
WalletSynchronizer(wallet, config).start()
diff --git a/lib/interface.py b/lib/interface.py
@@ -88,6 +88,28 @@ class Interface(threading.Thread):
with self.lock:
method, params, channel = self.unanswered_requests.pop(msg_id)
result = c.get('result')
+
+ if method == 'server.version':
+ self.server_version = result
+
+ elif method == 'server.peers.subscribe':
+ servers = []
+ for item in result:
+ s = []
+ host = item[1]
+ ports = []
+ version = None
+ if len(item) > 2:
+ for v in item[2]:
+ if re.match("[stgh]\d+", v):
+ ports.append((v[0], v[1:]))
+ if re.match("v(.?)+", v):
+ version = v[1:]
+ if ports and version:
+ servers.append((host, ports))
+ self.servers = servers
+ self.trigger_callback('peers')
+
else:
# notification: find the channel(s)
method = c.get('method')
diff --git a/lib/wallet.py b/lib/wallet.py
@@ -873,7 +873,6 @@ class WalletSynchronizer(threading.Thread):
self.interface.send([('server.banner',[])],'synchronizer')
# subscriptions
- self.interface.send([('server.peers.subscribe',[])],'synchronizer')
self.subscribe_to_addresses(self.wallet.all_addresses())
while True:
@@ -907,27 +906,6 @@ class WalletSynchronizer(threading.Thread):
self.wallet.tx_result = result
self.wallet.tx_event.set()
- elif method == 'server.version':
- pass
-
- elif method == 'server.peers.subscribe':
- servers = []
- for item in result:
- s = []
- host = item[1]
- ports = []
- version = None
- if len(item) > 2:
- for v in item[2]:
- if re.match("[stgh]\d+", v):
- ports.append((v[0], v[1:]))
- if re.match("v(.?)+", v):
- version = v[1:]
- if ports and version:
- servers.append((host, ports))
- self.interface.servers = servers
- self.interface.trigger_callback('peers')
-
elif method == 'server.banner':
self.wallet.banner = result
self.wallet.was_updated = True