Full Network Tab information API command

This commit is contained in:
Syndicalist 2013-08-06 19:31:02 -04:00
parent 8be018e9ac
commit 888a611f61
3 changed files with 22 additions and 6 deletions

View File

@ -740,8 +740,19 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
return data return data
elif method == 'clientStatus': elif method == 'clientStatus':
return '{ "networkConnections" : "%s" }' % str(len(shared.connectedHostsList)) return '{ "networkConnections" : "%s" }' % str(len(shared.connectedHostsList))
elif method == 'fullyConnected': elif method == 'networkTabInfo':
return '"%s"' % shared.definitelyFullyConnected data = '{\n \"Total Connections\" : "%s"\n' % str(len(shared.connectedHostsList))
data += ' \"P2P Messages Processed\" : "%s"\n' % str(shared.messagesTotals)
data += ' \"Broadcast Messages Processed\" : "%s"\n' % str(shared.broadcastTotals)
data += ' \"Public Keys Processed\" : "%s"\n' % str(shared.pubkeysTotals)
if len(shared.connectedHostsList) == 0:
dataColor = 'red'
elif len(shared.connectedHostsList) > 0 and not shared.definitelyFullyConnected:
dataColor = 'yellow'
else:
dataColor = 'green'
data += ' \"Icon Status\" : "%s"\n}' % dataColor
return data
else: else:
return 'API Error 0020: Invalid method: %s' % method return 'API Error 0020: Invalid method: %s' % method

View File

@ -395,7 +395,7 @@ class receiveDataThread(threading.Thread):
self.broadcastinv(self.inventoryHash) self.broadcastinv(self.inventoryHash)
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfBroadcastsProcessed', 'no data')) 'incrementNumberOfBroadcastsProcessed', 'no data'))
shared.broadcastTotals = shared.broadcastTotals + 1 # Used specifically for API
self.processbroadcast( self.processbroadcast(
readPosition, data) # When this function returns, we will have either successfully processed this broadcast because we are interested in it, ignored it because we aren't interested in it, or found problem with the broadcast that warranted ignoring it. readPosition, data) # When this function returns, we will have either successfully processed this broadcast because we are interested in it, ignored it because we aren't interested in it, or found problem with the broadcast that warranted ignoring it.
@ -763,7 +763,7 @@ class receiveDataThread(threading.Thread):
self.broadcastinv(self.inventoryHash) self.broadcastinv(self.inventoryHash)
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfMessagesProcessed', 'no data')) 'incrementNumberOfMessagesProcessed', 'no data'))
shared.messagesTotals = shared.messagesTotals + 1 # Used specifically for API
self.processmsg( self.processmsg(
readPosition, data) # When this function returns, we will have either successfully processed the message bound for us, ignored it because it isn't bound for us, or found problem with the message that warranted ignoring it. readPosition, data) # When this function returns, we will have either successfully processed the message bound for us, ignored it because it isn't bound for us, or found problem with the message that warranted ignoring it.
@ -1181,7 +1181,7 @@ class receiveDataThread(threading.Thread):
self.broadcastinv(inventoryHash) self.broadcastinv(inventoryHash)
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfPubkeysProcessed', 'no data')) 'incrementNumberOfPubkeysProcessed', 'no data'))
shared.pubkeysTotals = shared.pubkeysTotals + 1 # Used specifically for API
self.processpubkey(data) self.processpubkey(data)
lengthOfTimeWeShouldUseToProcessThisMessage = .2 lengthOfTimeWeShouldUseToProcessThisMessage = .2

View File

@ -47,7 +47,6 @@ inventory = {} #of objects (like msg payloads and pubkey payloads) Does not incl
inventoryLock = threading.Lock() #Guarantees that two receiveDataThreads don't receive and process the same message concurrently (probably sent by a malicious individual) inventoryLock = threading.Lock() #Guarantees that two receiveDataThreads don't receive and process the same message concurrently (probably sent by a malicious individual)
printLock = threading.Lock() printLock = threading.Lock()
appdata = '' #holds the location of the application data storage directory appdata = '' #holds the location of the application data storage directory
definitelyFullyConnected = False
statusIconColor = 'red' statusIconColor = 'red'
connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice. connectedHostsList = {} #List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice.
shutdown = 0 #Set to 1 by the doCleanShutdown function. Used to tell the proof of work worker threads to exit. shutdown = 0 #Set to 1 by the doCleanShutdown function. Used to tell the proof of work worker threads to exit.
@ -66,6 +65,12 @@ apiAddressGeneratorReturnQueue = Queue.Queue(
) # The address generator thread uses this queue to get information back to the API thread. ) # The address generator thread uses this queue to get information back to the API thread.
ackdataForWhichImWatching = {} ackdataForWhichImWatching = {}
# Network Tab information
messagesTotals = 0
broadcastTotals = 0
pubkeysTotals = 0
definitelyFullyConnected = False
#If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them! #If changed, these values will cause particularly unexpected behavior: You won't be able to either send or receive messages because the proof of work you do (or demand) won't match that done or demanded by others. Don't change them!
networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work. networkDefaultProofOfWorkNonceTrialsPerByte = 320 #The amount of work that should be performed (and demanded) per byte of the payload. Double this number to double the work.
networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target. networkDefaultPayloadLengthExtraBytes = 14000 #To make sending short messages a little more difficult, this value is added to the payload length for use in calculating the proof of work target.