Merge pull request #435 from Atheros1/master

show number of each message type processed in the API command clientStat...
This commit is contained in:
Jonathan Warren 2013-08-24 16:48:57 -07:00
commit 9a4d7a7801
4 changed files with 33 additions and 22 deletions

View File

@ -849,7 +849,13 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
data += ']}' data += ']}'
return data return data
elif method == 'clientStatus': elif method == 'clientStatus':
return '{ "networkConnections" : "%s" }' % str(len(shared.connectedHostsList)) if len(shared.connectedHostsList) == 0:
networkStatus = 'notConnected'
elif len(shared.connectedHostsList) > 0 and not shared.clientHasReceivedIncomingConnections:
networkStatus = 'connectedButHaveNotReceivedIncomingConnections'
else:
networkStatus = 'connectedAndReceivingIncomingConnections'
return json.dumps({'networkConnections':len(shared.connectedHostsList),'numberOfMessagesProcessed':shared.numberOfMessagesProcessed, 'numberOfBroadcastsProcessed':shared.numberOfBroadcastsProcessed, 'numberOfPubkeysProcessed':shared.numberOfPubkeysProcessed, 'networkStatus':networkStatus}, indent=4, separators=(',', ': '))
else: else:
return 'API Error 0020: Invalid method: %s' % method return 'API Error 0020: Invalid method: %s' % method

View File

@ -417,11 +417,11 @@ class MyForm(QtGui.QMainWindow):
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"updateNetworkStatusTab()"), self.updateNetworkStatusTab) "updateNetworkStatusTab()"), self.updateNetworkStatusTab)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfMessagesProcessed()"), self.incrementNumberOfMessagesProcessed) "updateNumberOfMessagesProcessed()"), self.updateNumberOfMessagesProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfPubkeysProcessed()"), self.incrementNumberOfPubkeysProcessed) "updateNumberOfPubkeysProcessed()"), self.updateNumberOfPubkeysProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"incrementNumberOfBroadcastsProcessed()"), self.incrementNumberOfBroadcastsProcessed) "updateNumberOfBroadcastsProcessed()"), self.updateNumberOfBroadcastsProcessed)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"setStatusIcon(PyQt_PyObject)"), self.setStatusIcon) "setStatusIcon(PyQt_PyObject)"), self.setStatusIcon)
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
@ -1260,20 +1260,17 @@ class MyForm(QtGui.QMainWindow):
self.actionShow.setChecked(not self.actionShow.isChecked()) self.actionShow.setChecked(not self.actionShow.isChecked())
self.appIndicatorShowOrHideWindow() self.appIndicatorShowOrHideWindow()
def incrementNumberOfMessagesProcessed(self): def updateNumberOfMessagesProcessed(self):
self.numberOfMessagesProcessed += 1
self.ui.labelMessageCount.setText(_translate( self.ui.labelMessageCount.setText(_translate(
"MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed))) "MainWindow", "Processed %1 person-to-person messages.").arg(str(shared.numberOfMessagesProcessed)))
def incrementNumberOfBroadcastsProcessed(self): def updateNumberOfBroadcastsProcessed(self):
self.numberOfBroadcastsProcessed += 1
self.ui.labelBroadcastCount.setText(_translate( self.ui.labelBroadcastCount.setText(_translate(
"MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed))) "MainWindow", "Processed %1 broadcast messages.").arg(str(shared.numberOfBroadcastsProcessed)))
def incrementNumberOfPubkeysProcessed(self): def updateNumberOfPubkeysProcessed(self):
self.numberOfPubkeysProcessed += 1
self.ui.labelPubkeyCount.setText(_translate( self.ui.labelPubkeyCount.setText(_translate(
"MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed))) "MainWindow", "Processed %1 public keys.").arg(str(shared.numberOfPubkeysProcessed)))
def updateNetworkStatusTab(self): def updateNetworkStatusTab(self):
# print 'updating network status tab' # print 'updating network status tab'
@ -3363,12 +3360,12 @@ class UISignaler(Thread,QThread):
toAddress, fromLabel, fromAddress, subject, message, ackdata) toAddress, fromLabel, fromAddress, subject, message, ackdata)
elif command == 'updateNetworkStatusTab': elif command == 'updateNetworkStatusTab':
self.emit(SIGNAL("updateNetworkStatusTab()")) self.emit(SIGNAL("updateNetworkStatusTab()"))
elif command == 'incrementNumberOfMessagesProcessed': elif command == 'updateNumberOfMessagesProcessed':
self.emit(SIGNAL("incrementNumberOfMessagesProcessed()")) self.emit(SIGNAL("updateNumberOfMessagesProcessed()"))
elif command == 'incrementNumberOfPubkeysProcessed': elif command == 'updateNumberOfPubkeysProcessed':
self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()")) self.emit(SIGNAL("updateNumberOfPubkeysProcessed()"))
elif command == 'incrementNumberOfBroadcastsProcessed': elif command == 'updateNumberOfBroadcastsProcessed':
self.emit(SIGNAL("incrementNumberOfBroadcastsProcessed()")) self.emit(SIGNAL("updateNumberOfBroadcastsProcessed()"))
elif command == 'setStatusIcon': elif command == 'setStatusIcon':
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data) self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data)
elif command == 'rerenderInboxFromLabels': elif command == 'rerenderInboxFromLabels':

View File

@ -256,6 +256,7 @@ class receiveDataThread(threading.Thread):
def connectionFullyEstablished(self): def connectionFullyEstablished(self):
self.connectionIsOrWasFullyEstablished = True self.connectionIsOrWasFullyEstablished = True
if not self.initiatedConnection: if not self.initiatedConnection:
shared.clientHasReceivedIncomingConnections = True
shared.UISignalQueue.put(('setStatusIcon', 'green')) shared.UISignalQueue.put(('setStatusIcon', 'green'))
self.sock.settimeout( self.sock.settimeout(
600) # We'll send out a pong every 5 minutes to make sure the connection stays alive if there has been no other traffic to send lately. 600) # We'll send out a pong every 5 minutes to make sure the connection stays alive if there has been no other traffic to send lately.
@ -392,8 +393,9 @@ class receiveDataThread(threading.Thread):
objectType, self.streamNumber, data, embeddedTime) objectType, self.streamNumber, data, embeddedTime)
shared.inventoryLock.release() shared.inventoryLock.release()
self.broadcastinv(self.inventoryHash) self.broadcastinv(self.inventoryHash)
shared.numberOfBroadcastsProcessed += 1
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfBroadcastsProcessed', 'no data')) 'updateNumberOfBroadcastsProcessed', 'no data'))
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.
@ -760,8 +762,9 @@ class receiveDataThread(threading.Thread):
objectType, self.streamNumber, data, embeddedTime) objectType, self.streamNumber, data, embeddedTime)
shared.inventoryLock.release() shared.inventoryLock.release()
self.broadcastinv(self.inventoryHash) self.broadcastinv(self.inventoryHash)
shared.numberOfMessagesProcessed += 1
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfMessagesProcessed', 'no data')) 'updateNumberOfMessagesProcessed', 'no data'))
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.
@ -1178,8 +1181,9 @@ class receiveDataThread(threading.Thread):
objectType, self.streamNumber, data, embeddedTime) objectType, self.streamNumber, data, embeddedTime)
shared.inventoryLock.release() shared.inventoryLock.release()
self.broadcastinv(inventoryHash) self.broadcastinv(inventoryHash)
shared.numberOfPubkeysProcessed += 1
shared.UISignalQueue.put(( shared.UISignalQueue.put((
'incrementNumberOfPubkeysProcessed', 'no data')) 'updateNumberOfPubkeysProcessed', 'no data'))
self.processpubkey(data) self.processpubkey(data)

View File

@ -64,6 +64,10 @@ successfullyDecryptMessageTimings = [
apiAddressGeneratorReturnQueue = Queue.Queue( 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 = {}
clientHasReceivedIncomingConnections = False #used by API command clientStatus
numberOfMessagesProcessed = 0
numberOfBroadcastsProcessed = 0
numberOfPubkeysProcessed = 0
#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.