From e522f015a8351029733d09f5593e01bb164fcbb6 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 31 May 2017 10:15:47 +0200 Subject: [PATCH] Network status updates - only update processed numbers once every 2 seconds - moved inventory lookups to the main inventory so now all storage modules work with it --- src/bitmessageqt/networkstatus.py | 9 ++++++--- src/inventory.py | 3 +++ src/storage/sqlite.py | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bitmessageqt/networkstatus.py b/src/bitmessageqt/networkstatus.py index ef9e4c42..ce30b4c7 100644 --- a/src/bitmessageqt/networkstatus.py +++ b/src/bitmessageqt/networkstatus.py @@ -49,17 +49,17 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin): self.labelSyncStatus.setText(_translate("networkstatus", "Object(s) to be synced: %n", None, QtCore.QCoreApplication.CodecForTr, network.stats.pendingDownload() + network.stats.pendingUpload())) def updateNumberOfMessagesProcessed(self): - self.updateNumberOfObjectsToBeSynced() +# self.updateNumberOfObjectsToBeSynced() self.labelMessageCount.setText(_translate( "networkstatus", "Processed %n person-to-person message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfMessagesProcessed)) def updateNumberOfBroadcastsProcessed(self): - self.updateNumberOfObjectsToBeSynced() +# self.updateNumberOfObjectsToBeSynced() self.labelBroadcastCount.setText(_translate( "networkstatus", "Processed %n broadcast message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfBroadcastsProcessed)) def updateNumberOfPubkeysProcessed(self): - self.updateNumberOfObjectsToBeSynced() +# self.updateNumberOfObjectsToBeSynced() self.labelPubkeyCount.setText(_translate( "networkstatus", "Processed %n public key(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfPubkeysProcessed)) @@ -128,6 +128,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin): Inventory().numberOfInventoryLookupsPerformed = 0 self.updateNumberOfBytes() self.updateNumberOfObjectsToBeSynced() + self.updateNumberOfMessagesProcessed() + self.updateNumberOfBroadcastsProcessed() + self.updateNumberOfPubkeysProcessed() def retranslateUi(self): super(QtGui.QWidget, self).retranslateUi() diff --git a/src/inventory.py b/src/inventory.py index b676415b..598021fb 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -23,10 +23,13 @@ class Inventory(): self._className = "storage." + self._moduleName + "." + self._moduleName.title() + "Inventory" self._inventoryClass = eval(self._className) self._realInventory = self._inventoryClass() + self.numberOfInventoryLookupsPerformed = 0 # cheap inheritance copied from asyncore def __getattr__(self, attr): try: + if attr == "__contains__": + self.numberOfInventoryLookupsPerformed += 1 realRet = getattr(self._realInventory, attr) except AttributeError: raise AttributeError("%s instance has no attribute '%s'" %(self.__class__.__name__, attr)) diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 38e9c0a2..96733a36 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -15,7 +15,6 @@ class SqliteInventory(InventoryStorage): def __contains__(self, hash): with self.lock: - self.numberOfInventoryLookupsPerformed += 1 if hash in self._inventory: return True return bool(sqlQuery('SELECT 1 FROM inventory WHERE hash=?', hash))