- replace PendingDownload singleton dict with a Queue
- total memory and CPU requirements should be reduced
- get rid of somObjectsOfWhichThisRemoteNodeIsAlearedyAware. It has very
little practicle effect and only uses memory
_translate("MainWindow","Bitmessage hasn't synchronised with the network, %n object(s) to be downloaded. If you quit now, it may cause delivery delays. Wait until the synchronisation finishes?",None,QtCore.QCoreApplication.CodecForTr,PendingDownload().len()),
_translate("MainWindow","Bitmessage hasn't synchronised with the network, %n object(s) to be downloaded. If you quit now, it may cause delivery delays. Wait until the synchronisation finishes?",None,QtCore.QCoreApplication.CodecForTr,PendingDownloadQueue.totalSize()),
@ -45,7 +46,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
return"%4.0f kB"%num
defupdateNumberOfObjectsToBeSynced(self):
self.labelSyncStatus.setText(_translate("networkstatus","Object(s) to be synced: %n",None,QtCore.QCoreApplication.CodecForTr,PendingDownload().len()+PendingUpload().len()))
self.labelSyncStatus.setText(_translate("networkstatus","Object(s) to be synced: %n",None,QtCore.QCoreApplication.CodecForTr,PendingDownloadQueue.totalSize()+PendingUpload().len()))
logger.info('inv message lists %s objects. Of those %s are new to me. It took %s seconds to figure that out.',numberOfItemsInInv,len(objectsNewToMe),time.time()-startTime)
foriteminobjectsNewToMe:
PendingDownload().add(item)
self.someObjectsOfWhichThisRemoteNodeIsAlreadyAware[item]=0# helps us keep from sending inv messages to peers that already know about the objects listed therein
self.downloadQueue.put(item)
# Send a getdata message to our peer to request the object with the given
@ -176,7 +174,6 @@ class sendDataThread(threading.Thread):
logger.error('sendinv: self.sock.sendall failed')
break
elifcommand=='pong':
self.someObjectsOfWhichThisRemoteNodeIsAlreadyAware.clear()# To save memory, let us clear this data structure from time to time. As its function is to help us keep from sending inv messages to peers which sent us the same inv message mere seconds earlier, it will be fine to clear this data structure from time to time.
ifself.lastTimeISentData<(int(time.time())-298):
# Send out a pong message to keep the connection alive.
logger.debug('Sending pong to '+str(self.peer)+' to keep connection alive.')