fix: inheritance
This commit is contained in:
parent
ca3fa8c6dd
commit
10119dfed3
|
@ -109,7 +109,8 @@ class InterfaceAncestor(threading.Thread):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PollingInterface(InterfaceAncestor):
|
|
||||||
|
class HttpStratumInterface(InterfaceAncestor):
|
||||||
""" non-persistent connection. synchronous calls"""
|
""" non-persistent connection. synchronous calls"""
|
||||||
|
|
||||||
def __init__(self, host, port, proxy=None):
|
def __init__(self, host, port, proxy=None):
|
||||||
|
@ -119,9 +120,6 @@ class PollingInterface(InterfaceAncestor):
|
||||||
def get_history(self, address):
|
def get_history(self, address):
|
||||||
self.send([('blockchain.address.get_history', [address] )])
|
self.send([('blockchain.address.get_history', [address] )])
|
||||||
|
|
||||||
def poll(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.is_connected = True
|
self.is_connected = True
|
||||||
while self.is_connected:
|
while self.is_connected:
|
||||||
|
@ -141,15 +139,6 @@ class PollingInterface(InterfaceAncestor):
|
||||||
self.poke()
|
self.poke()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HttpStratumInterface(PollingInterface):
|
|
||||||
|
|
||||||
def poll(self):
|
def poll(self):
|
||||||
self.send([])
|
self.send([])
|
||||||
|
|
||||||
|
@ -308,6 +297,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
|
||||||
host, port, protocol = s.split(':')
|
host, port, protocol = s.split(':')
|
||||||
port = int(port)
|
port = int(port)
|
||||||
|
|
||||||
|
self.protocol = protocol
|
||||||
proxy = self.parse_proxy_options(config.get('proxy','none'))
|
proxy = self.parse_proxy_options(config.get('proxy','none'))
|
||||||
self.server = host + ':%d:%s'%(port, protocol)
|
self.server = host + ':%d:%s'%(port, protocol)
|
||||||
|
|
||||||
|
@ -321,6 +311,19 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
|
||||||
TcpStratumInterface.__init__(self, host, port, proxy)
|
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):
|
def parse_proxy_options(self, s):
|
||||||
if type(s) != type(""): return None
|
if type(s) != type(""): return None
|
||||||
if s.lower() == 'none': return None
|
if s.lower() == 'none': return None
|
||||||
|
|
Loading…
Reference in New Issue