- it shows that it needs to wait for PoW to finish
- it waits a bit for new objects to be distributed
- it displays a better progress indicator in the status bar
Previously, people who don't understand how PyBitmessage works sometimes
shut it down immediately after they wrote a message. This would have
caused the message to be stuck in the queue locally and not sent. Now,
it will indicate that the PoW still needs to work, and it will wait a
bit longer so that the message can spread. It's not a completely correct
approach, because it does not know whether the message was really
retrieved after the "inv" notification was sent.
@ -2644,7 +2646,64 @@ class MyForm(settingsmixin.SMainWindow):
ifreplyisQtGui.QMessageBox.No:
return
'''
self.statusBar().showMessage(_translate(
"MainWindow","Shutting down PyBitmessage... %1%%").arg(str(0)))
# check if PoW queue empty
maxWorkerQueue=0
curWorkerQueue=1
whilecurWorkerQueue>0:
# worker queue size
curWorkerQueue=shared.workerQueue.qsize()
# if worker is busy add 1
forthreadinthreading.enumerate():
try:
ifisinstance(thread,singleWorker):
curWorkerQueue+=thread.busy
except:
pass
ifcurWorkerQueue>maxWorkerQueue:
maxWorkerQueue=curWorkerQueue
ifcurWorkerQueue>0:
self.statusBar().showMessage(_translate("MainWindow","Waiting for PoW to finish... %1%").arg(str(50*(maxWorkerQueue-curWorkerQueue)/maxWorkerQueue)))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents()
self.statusBar().showMessage(_translate("MainWindow","Shutting down Pybitmessage... %1%").arg(str(50)))
QtCore.QCoreApplication.processEvents()
ifmaxWorkerQueue>0:
time.sleep(0.5)# a bit of time so that the hashHolder is populated
QtCore.QCoreApplication.processEvents()
# check if objectHashHolder empty
self.statusBar().showMessage(_translate("MainWindow","Waiting for objects to be sent... %1%").arg(str(50)))
maxWaitingObjects=0
curWaitingObjects=1
whilecurWaitingObjects>0:
curWaitingObjects=0
forthreadinthreading.enumerate():
try:
ifisinstance(thread,objectHashHolder):
curWaitingObjects+=thread.hashCount()
except:
pass
ifcurWaitingObjects>maxWaitingObjects:
maxWaitingObjects=curWaitingObjects
ifcurWaitingObjects>0:
self.statusBar().showMessage(_translate("MainWindow","Waiting for objects to be sent... %1%").arg(str(50+20*(maxWaitingObjects-curWaitingObjects)/maxWaitingObjects)))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents()
QtCore.QCoreApplication.processEvents()
ifmaxWorkerQueue>0ormaxWaitingObjects>0:
time.sleep(10)# a bit of time so that the other nodes retrieve the objects