electrum

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

commit 10119dfed31bab7a59032df83f67824e74836eb9
parent ca3fa8c6ddeee7f046f1fa762dde13d918cd0187
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 12 Oct 2012 01:13:54 +0200

fix: inheritance

Diffstat:
Mlib/interface.py | 29++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -109,7 +109,8 @@ class InterfaceAncestor(threading.Thread): -class PollingInterface(InterfaceAncestor): + +class HttpStratumInterface(InterfaceAncestor): """ non-persistent connection. synchronous calls""" def __init__(self, host, port, proxy=None): @@ -119,9 +120,6 @@ class PollingInterface(InterfaceAncestor): def get_history(self, address): self.send([('blockchain.address.get_history', [address] )]) - def poll(self): - pass - def run(self): self.is_connected = True while self.is_connected: @@ -141,15 +139,6 @@ class PollingInterface(InterfaceAncestor): self.poke() - - - - - - - -class HttpStratumInterface(PollingInterface): - def poll(self): self.send([]) @@ -308,6 +297,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface): host, port, protocol = s.split(':') port = int(port) + self.protocol = protocol proxy = self.parse_proxy_options(config.get('proxy','none')) self.server = host + ':%d:%s'%(port, protocol) @@ -321,6 +311,19 @@ class Interface(TcpStratumInterface, HttpStratumInterface): TcpStratumInterface.__init__(self, host, port, proxy) + def run(self): + if self.protocol == 't': + TcpStratumInterface.run(self) + else: + HttpStratumInterface.run(self) + + def send(self, messages): + if self.protocol == 't': + TcpStratumInterface.send(self, messages) + else: + HttpStratumInterface.send(self, messages) + + def parse_proxy_options(self, s): if type(s) != type(""): return None if s.lower() == 'none': return None