diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 2a0762c1..099fa42a 100644 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -740,8 +740,19 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): return data elif method == 'clientStatus': return '{ "networkConnections" : "%s" }' % str(len(shared.connectedHostsList)) - elif method == 'fullyConnected': - return '"%s"' % shared.definitelyFullyConnected + elif method == 'networkTabInfo': + 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: return 'API Error 0020: Invalid method: %s' % method diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index fd697d64..d42cad3f 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -395,7 +395,7 @@ class receiveDataThread(threading.Thread): self.broadcastinv(self.inventoryHash) shared.UISignalQueue.put(( 'incrementNumberOfBroadcastsProcessed', 'no data')) - + shared.broadcastTotals = shared.broadcastTotals + 1 # Used specifically for API 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. @@ -763,7 +763,7 @@ class receiveDataThread(threading.Thread): self.broadcastinv(self.inventoryHash) shared.UISignalQueue.put(( 'incrementNumberOfMessagesProcessed', 'no data')) - + shared.messagesTotals = shared.messagesTotals + 1 # Used specifically for API 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. @@ -1181,7 +1181,7 @@ class receiveDataThread(threading.Thread): self.broadcastinv(inventoryHash) shared.UISignalQueue.put(( 'incrementNumberOfPubkeysProcessed', 'no data')) - + shared.pubkeysTotals = shared.pubkeysTotals + 1 # Used specifically for API self.processpubkey(data) lengthOfTimeWeShouldUseToProcessThisMessage = .2 diff --git a/src/shared.py b/src/shared.py index 178db7df..c9e965bd 100644 --- a/src/shared.py +++ b/src/shared.py @@ -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) printLock = threading.Lock() appdata = '' #holds the location of the application data storage directory -definitelyFullyConnected = False 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. 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. 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! 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.