Adding user enabled debug messages for server communications
This commit is contained in:
parent
a48d68ebd0
commit
22fcb9e521
|
@ -49,7 +49,7 @@ def old_to_new(d):
|
||||||
|
|
||||||
|
|
||||||
class Interface(threading.Thread):
|
class Interface(threading.Thread):
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port, debug_server):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
self.host = host
|
self.host = host
|
||||||
|
@ -67,6 +67,8 @@ class Interface(threading.Thread):
|
||||||
self.responses = Queue.Queue()
|
self.responses = Queue.Queue()
|
||||||
self.unanswered_requests = {}
|
self.unanswered_requests = {}
|
||||||
|
|
||||||
|
self.debug_server = debug_server
|
||||||
|
|
||||||
def init_socket(self):
|
def init_socket(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -76,7 +78,9 @@ class Interface(threading.Thread):
|
||||||
|
|
||||||
def queue_json_response(self, c):
|
def queue_json_response(self, c):
|
||||||
|
|
||||||
#print "<--",c
|
if self.debug_server:
|
||||||
|
print "<--",c
|
||||||
|
|
||||||
msg_id = c.get('id')
|
msg_id = c.get('id')
|
||||||
error = c.get('error')
|
error = c.get('error')
|
||||||
|
|
||||||
|
@ -117,9 +121,10 @@ class Interface(threading.Thread):
|
||||||
class PollingInterface(Interface):
|
class PollingInterface(Interface):
|
||||||
""" non-persistent connection. synchronous calls"""
|
""" non-persistent connection. synchronous calls"""
|
||||||
|
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port, debug_server):
|
||||||
Interface.__init__(self, host, port)
|
Interface.__init__(self, host, port, debug_server)
|
||||||
self.session_id = None
|
self.session_id = None
|
||||||
|
self.debug_server = debug_server
|
||||||
|
|
||||||
def get_history(self, address):
|
def get_history(self, address):
|
||||||
self.send([('blockchain.address.get_history', [address] )])
|
self.send([('blockchain.address.get_history', [address] )])
|
||||||
|
@ -227,8 +232,9 @@ class HttpStratumInterface(PollingInterface):
|
||||||
class TcpStratumInterface(Interface):
|
class TcpStratumInterface(Interface):
|
||||||
"""json-rpc over persistent TCP connection, asynchronous"""
|
"""json-rpc over persistent TCP connection, asynchronous"""
|
||||||
|
|
||||||
def __init__(self, host, port):
|
def __init__(self, host, port, debug_server):
|
||||||
Interface.__init__(self, host, port)
|
Interface.__init__(self, host, port, debug_server)
|
||||||
|
self.debug_server = debug_server
|
||||||
|
|
||||||
def init_socket(self):
|
def init_socket(self):
|
||||||
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
|
||||||
|
@ -279,7 +285,10 @@ class TcpStratumInterface(Interface):
|
||||||
method, params = m
|
method, params = m
|
||||||
request = json.dumps( { 'id':self.message_id, 'method':method, 'params':params } )
|
request = json.dumps( { 'id':self.message_id, 'method':method, 'params':params } )
|
||||||
self.unanswered_requests[self.message_id] = method, params
|
self.unanswered_requests[self.message_id] = method, params
|
||||||
#print "-->",request
|
|
||||||
|
if self.debug_server:
|
||||||
|
print "-->",request
|
||||||
|
|
||||||
self.message_id += 1
|
self.message_id += 1
|
||||||
out += request + '\n'
|
out += request + '\n'
|
||||||
|
|
||||||
|
@ -321,7 +330,7 @@ class WalletSynchronizer(threading.Thread):
|
||||||
print "unknown protocol"
|
print "unknown protocol"
|
||||||
InterfaceClass = TcpStratumInterface
|
InterfaceClass = TcpStratumInterface
|
||||||
|
|
||||||
self.interface = InterfaceClass(host, port)
|
self.interface = InterfaceClass(host, port, self.wallet.debug_server)
|
||||||
self.wallet.interface = self.interface
|
self.wallet.interface = self.interface
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -277,6 +277,7 @@ class Wallet:
|
||||||
self.receipts = {} # signed URIs
|
self.receipts = {} # signed URIs
|
||||||
self.receipt = None # next receipt
|
self.receipt = None # next receipt
|
||||||
self.addressbook = [] # outgoing addresses, for payments
|
self.addressbook = [] # outgoing addresses, for payments
|
||||||
|
self.debug_server = False # write server communication debug info to stdout
|
||||||
|
|
||||||
# not saved
|
# not saved
|
||||||
self.tx_history = {}
|
self.tx_history = {}
|
||||||
|
@ -638,6 +639,7 @@ class Wallet:
|
||||||
'prioritized_addresses':self.prioritized_addresses,
|
'prioritized_addresses':self.prioritized_addresses,
|
||||||
'expert_mode':self.expert_mode,
|
'expert_mode':self.expert_mode,
|
||||||
'gap_limit':self.gap_limit,
|
'gap_limit':self.gap_limit,
|
||||||
|
'debug_server':self.debug_server,
|
||||||
}
|
}
|
||||||
f = open(self.path,"w")
|
f = open(self.path,"w")
|
||||||
f.write( repr(s) )
|
f.write( repr(s) )
|
||||||
|
@ -681,6 +683,7 @@ class Wallet:
|
||||||
self.prioritized_addresses = d.get('prioritized_addresses',[])
|
self.prioritized_addresses = d.get('prioritized_addresses',[])
|
||||||
self.expert_mode = d.get('expert_mode',False)
|
self.expert_mode = d.get('expert_mode',False)
|
||||||
self.gap_limit = d.get('gap_limit',5)
|
self.gap_limit = d.get('gap_limit',5)
|
||||||
|
self.debug_server = d.get('debug_server',True)
|
||||||
except:
|
except:
|
||||||
raise BaseException("cannot read wallet file")
|
raise BaseException("cannot read wallet file")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue