tfix: inheritance - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 10119dfed31bab7a59032df83f67824e74836eb9 DIR parent ca3fa8c6ddeee7f046f1fa762dde13d918cd0187 HTML Author: ThomasV <thomasv@gitorious> Date: Fri, 12 Oct 2012 01:13:54 +0200 fix: inheritance Diffstat: M lib/interface.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) --- DIR diff --git a/lib/interface.py b/lib/interface.py t@@ -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): t@@ -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: t@@ -141,15 +139,6 @@ class PollingInterface(InterfaceAncestor): self.poke() - - - - - - - -class HttpStratumInterface(PollingInterface): - def poll(self): self.send([]) t@@ -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) t@@ -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