electrum

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

commit b286c14ab582dce50192661a712ee41992241c89
parent 0ab4ecfdbf0d607bb3bf665176273e387f261d79
Author: ThomasV <thomasv@gitorious>
Date:   Sun, 25 Mar 2012 08:53:23 +0200

separate start and start_session

Diffstat:
Mclient/blocks | 3++-
Mclient/interface.py | 24++++++++++++------------
Mclient/wallet.py | 3+--
3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/client/blocks b/client/blocks @@ -3,7 +3,8 @@ import socket, time, interface i = interface.AsynchronousInterface('ecdsa.org', 50001) -i.start_session([],"blocks") +i.start() +i.send([('numblocks.subscribe',[])]) while True: r = i.responses.get(True, 100000000000) diff --git a/client/interface.py b/client/interface.py @@ -107,16 +107,16 @@ class Interface: traceback.print_exc(file=sys.stdout) - + def start_session(self, addresses, version): + #print "Starting new session: %s:%d"%(self.host,self.port) + self.start() + self.send([('client.version', [version]), ('server.banner',[]), ('numblocks.subscribe',[]), ('server.peers',[])]) + self.subscribe(addresses) class PollingInterface(Interface): """ non-persistent connection. synchronous calls""" - def start_session(self, addresses, version): - self.send([('session.new', [ version, addresses ])] ) - self.send([('server.peers',[])]) - thread.start_new_thread(self.poll_thread, (5,)) def get_history(self, address): self.send([('address.get_history', [address] )]) @@ -156,6 +156,11 @@ class PollingInterface(Interface): class NativeInterface(PollingInterface): + def start_session(self, addresses, version): + self.send([('session.new', [ version, addresses ])] ) + self.send([('server.peers',[])]) + thread.start_new_thread(self.poll_thread, (5,)) + def send(self, messages): import time cmds = {'session.new':'new_session', @@ -214,10 +219,8 @@ class NativeInterface(PollingInterface): class HttpInterface(PollingInterface): - def start_session(self, addresses, version): + def start(self): self.session_id = None - self.send([('client.version', [version]), ('server.banner',[]), ('numblocks.subscribe',[]), ('server.peers',[])]) - self.subscribe(addresses) thread.start_new_thread(self.poll_thread, (15,)) def poll(self): @@ -316,15 +319,12 @@ class AsynchronousInterface(Interface): self.send([('address.get_history', [addr])]) self.addresses_waiting_for_history.append(addr) - def start_session(self, addresses, version): + def start(self): self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) self.s.settimeout(5) self.s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) - self.s.connect(( self.host, self.port)) thread.start_new_thread(self.listen_thread, ()) - self.send([('client.version', [version]), ('server.banner',[]), ('numblocks.subscribe',[]), ('server.peers',[])]) - self.subscribe(addresses) diff --git a/client/wallet.py b/client/wallet.py @@ -991,7 +991,6 @@ class Wallet: self.interface = InterfaceClass(self.host, self.port) addresses = self.all_addresses() version = self.electrum_version - self.interface.start_session(addresses, version) - #print "Starting new session: %s:%d"%(self.host,self.port) + self.interface.start_session(addresses,version)