tmove 'peers.subscribe' and 'server.version' calls into the interface - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit cfb3aa6a12c44039e08a59e0ec5b649c0ffda053 (DIR) parent 18c9c2f3696e02381fd7d2e7cc38c21896173cca (HTM) Author: ThomasV <thomasv@gitorious> Date: Sat, 27 Oct 2012 14:15:03 +0200 move 'peers.subscribe' and 'server.version' calls into the interface Diffstat: M electrum | 1 + M lib/interface.py | 22 ++++++++++++++++++++++ M lib/wallet.py | 22 ---------------------- 3 files changed, 23 insertions(+), 22 deletions(-) --- (DIR) diff --git a/electrum b/electrum t@@ -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() (DIR) diff --git a/lib/interface.py b/lib/interface.py t@@ -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') (DIR) diff --git a/lib/wallet.py b/lib/wallet.py t@@ -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: t@@ -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