Bugfix: infinite loop if our max acceptable difficulty is too low
This commit is contained in:
parent
fdb0d1e776
commit
713ed89467
|
@ -2347,12 +2347,31 @@ class MyForm(QtGui.QMainWindow):
|
|||
if float(self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) >= 1:
|
||||
shared.config.set('bitmessagesettings', 'defaultpayloadlengthextrabytes', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
acceptableDifficultyChanged = False
|
||||
|
||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) == 0:
|
||||
shared.config.set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
if shared.config.get('bitmessagesettings','maxacceptablenoncetrialsperbyte') != str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)):
|
||||
# the user changed the max acceptable total difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
shared.config.set('bitmessagesettings', 'maxacceptablenoncetrialsperbyte', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableTotalDifficulty.text()) * shared.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
if float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or float(self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0:
|
||||
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
||||
if shared.config.get('bitmessagesettings','maxacceptablepayloadlengthextrabytes') != str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)):
|
||||
# the user changed the max acceptable small message difficulty
|
||||
acceptableDifficultyChanged = True
|
||||
shared.config.set('bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', str(int(float(
|
||||
self.settingsDialogInstance.ui.lineEditMaxAcceptableSmallMessageDifficulty.text()) * shared.networkDefaultPayloadLengthExtraBytes)))
|
||||
if acceptableDifficultyChanged:
|
||||
# It might now be possible to send msgs which were previously marked as toodifficult.
|
||||
# Let us change them to 'msgqueued'. The singleWorker will try to send them and will again
|
||||
# mark them as toodifficult if the receiver's required difficulty is still higher than
|
||||
# we are willing to do.
|
||||
sqlExecute('''UPDATE sent SET status='msgqueued' WHERE status='toodifficult' ''')
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
|
||||
#start:UI setting to stop trying to send messages after X days/months
|
||||
# I'm open to changing this UI to something else if someone has a better idea.
|
||||
if ((self.settingsDialogInstance.ui.lineEditDays.text()=='') and (self.settingsDialogInstance.ui.lineEditMonths.text()=='')):#We need to handle this special case. Bitmessage has its default behavior. The input is blank/blank
|
||||
|
|
|
@ -515,14 +515,9 @@ class singleWorker(threading.Thread):
|
|||
def sendMsg(self):
|
||||
while True: # while we have a msg that needs some work
|
||||
|
||||
# Select just one msg that needs work. We'll get a msg
|
||||
# which is ready to be sent or a msg which we have sent in
|
||||
# the last 28 days which were previously marked
|
||||
# as 'toodifficult'. If the user has raised the maximum acceptable
|
||||
# difficulty then those msgs may now be sendable.
|
||||
# Select just one msg that needs work.
|
||||
queryreturn = sqlQuery(
|
||||
'''SELECT toaddress, toripe, fromaddress, subject, message, ackdata, status FROM sent WHERE (status='msgqueued' or status='doingmsgpow' or status='forcepow' or (status='toodifficult' and lastactiontime>?)) and folder='sent' LIMIT 1''',
|
||||
int(time.time()) - 2419200)
|
||||
'''SELECT toaddress, toripe, fromaddress, subject, message, ackdata, status FROM sent WHERE (status='msgqueued' or status='doingmsgpow' or status='forcepow') and folder='sent' LIMIT 1''')
|
||||
if len(queryreturn) == 0: # if there is no work to do then
|
||||
break # break out of this sendMsg loop and
|
||||
# wait for something to get put in the shared.workerQueue.
|
||||
|
@ -717,7 +712,7 @@ class singleWorker(threading.Thread):
|
|||
sqlExecute(
|
||||
'''UPDATE sent SET status='toodifficult' WHERE ackdata=? ''',
|
||||
ackdata)
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr.translateText("MainWindow", "Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do.").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte) / shared.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (ackdata, tr.translateText("MainWindow", "Problem: The work demanded by the recipient (%1 and %2) is more difficult than you are willing to do. %3").arg(str(float(requiredAverageProofOfWorkNonceTrialsPerByte) / shared.networkDefaultProofOfWorkNonceTrialsPerByte)).arg(str(float(
|
||||
requiredPayloadLengthExtraBytes) / shared.networkDefaultPayloadLengthExtraBytes)).arg(l10n.formatTimestamp()))))
|
||||
continue
|
||||
else: # if we are sending a message to ourselves or a chan..
|
||||
|
|
Loading…
Reference in New Issue
Block a user