tdebugging options should not be parameters, it makes the code unnecessarily complictated - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 44dd7713e5fdc3333899cca070f03f7b6d72c380 (DIR) parent 8fd1dbadf65c8a4b837f73f40b1e1e53a36b8a80 (HTM) Author: thomasv <thomasv@gitorious> Date: Mon, 1 Oct 2012 17:41:47 +0200 debugging options should not be parameters, it makes the code unnecessarily complictated Diffstat: M lib/interface.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) --- (DIR) diff --git a/lib/interface.py b/lib/interface.py t@@ -65,7 +65,7 @@ def parse_proxy_options(s): return proxy class Interface(threading.Thread): - def __init__(self, host, port, debug_server, proxy): + def __init__(self, host, port, proxy): threading.Thread.__init__(self) self.daemon = True self.host = host t@@ -84,8 +84,6 @@ class Interface(threading.Thread): self.responses = Queue.Queue() self.unanswered_requests = {} - self.debug_server = debug_server - def init_socket(self): pass t@@ -95,8 +93,8 @@ class Interface(threading.Thread): def queue_json_response(self, c): - if self.debug_server: - print "<--",c + # uncomment to debug + # print "<--",c msg_id = c.get('id') error = c.get('error') t@@ -138,10 +136,9 @@ class Interface(threading.Thread): class PollingInterface(Interface): """ non-persistent connection. synchronous calls""" - def __init__(self, host, port, debug_server, proxy): - Interface.__init__(self, host, port, debug_server, proxy) + def __init__(self, host, port, proxy): + Interface.__init__(self, host, port, proxy) self.session_id = None - self.debug_server = debug_server def get_history(self, address): self.send([('blockchain.address.get_history', [address] )]) t@@ -253,9 +250,8 @@ class HttpStratumInterface(PollingInterface): class TcpStratumInterface(Interface): """json-rpc over persistent TCP connection, asynchronous""" - def __init__(self, host, port, debug_server, proxy): - Interface.__init__(self, host, port, debug_server, proxy) - self.debug_server = debug_server + def __init__(self, host, port, proxy): + Interface.__init__(self, host, port, proxy) def init_socket(self): global proxy_modes t@@ -314,8 +310,8 @@ class TcpStratumInterface(Interface): request = json.dumps( { 'id':self.message_id, 'method':method, 'params':params } ) self.unanswered_requests[self.message_id] = method, params - if self.debug_server: - print "-->",request + # uncomment to debug + # print "-->",request self.message_id += 1 out += request + '\n' t@@ -360,7 +356,7 @@ class WalletSynchronizer(threading.Thread): print_error("Error: Unknown protocol") InterfaceClass = TcpStratumInterface - self.interface = InterfaceClass(host, port, self.wallet.debug_server, self.proxy) + self.interface = InterfaceClass(host, port, self.proxy) self.wallet.interface = self.interface def handle_response(self, r):