Refactoring various SQL into helper_sent.py
This commit is contained in:
parent
bfdb04716a
commit
9c5104d2e1
|
@ -814,13 +814,7 @@ class receiveDataThread(threading.Thread):
|
|||
shared.printLock.release()
|
||||
del shared.ackdataForWhichImWatching[encryptedData[readPosition:]]
|
||||
t = ('ackreceived', encryptedData[readPosition:])
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(
|
||||
'UPDATE sent SET status=? WHERE ackdata=?')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
helper_sent.updateStatusByAckData(t)
|
||||
shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (encryptedData[readPosition:], tr.translateText("MainWindow",'Acknowledgement of the message received. %1').arg(unicode(
|
||||
time.strftime(shared.config.get('bitmessagesettings', 'timeformat'), time.localtime(int(time.time()))), 'utf-8')))))
|
||||
return
|
||||
|
@ -1115,13 +1109,7 @@ class receiveDataThread(threading.Thread):
|
|||
print 'We have been awaiting the arrival of this pubkey.'
|
||||
del shared.neededPubkeys[toRipe]
|
||||
t = (toRipe,)
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET status='doingmsgpow' WHERE toripe=? AND (status='awaitingpubkey' or status='doingpubkeypow') and folder='sent' ''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
helper_sent.updateStatusForPossibleNewPubKey(t)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
else:
|
||||
shared.printLock.acquire()
|
||||
|
|
|
@ -2,6 +2,7 @@ import threading
|
|||
import shared
|
||||
import time
|
||||
import sys
|
||||
import helper_sent
|
||||
|
||||
'''The singleCleaner class is a timer-driven thread that cleans data structures to free memory, resends messages when a remote node doesn't respond, and sends pong messages to keep connections alive if the network isn't busy.
|
||||
It cleans these data structures in memory:
|
||||
|
@ -98,22 +99,14 @@ class singleCleaner(threading.Thread):
|
|||
'updateStatusBar', 'Doing work necessary to again attempt to request a public key...'))
|
||||
t = (int(
|
||||
time.time()), pubkeyretrynumber + 1, toripe)
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
helper_sent.updateStatusForRerequestPubKey(t)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
else: # status == msgsent
|
||||
if int(time.time()) - lastactiontime > (shared.maximumAgeOfAnObjectThatIAmWillingToAccept * (2 ** (msgretrynumber))):
|
||||
print 'It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.'
|
||||
t = (int(
|
||||
time.time()), msgretrynumber + 1, 'msgqueued', ackdata)
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
helper_sent.updateStatusForResend(t)
|
||||
shared.workerQueue.put(('sendmessage', ''))
|
||||
shared.UISignalQueue.put((
|
||||
'updateStatusBar', 'Doing work necessary to again attempt to deliver a message...'))
|
||||
|
|
|
@ -9,3 +9,34 @@ def insert(t):
|
|||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
|
||||
def updateStatusByAckData(t):
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(
|
||||
'UPDATE sent SET status=? WHERE ackdata=?')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
|
||||
def updateStatusForPossibleNewPubKey(t):
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET status='doingmsgpow' WHERE toripe=? AND (status='awaitingpubkey' or status='doingpubkeypow') and folder='sent' ''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
shared.sqlLock.release()
|
||||
|
||||
def updateStatusForResend(t):
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET lastactiontime=?, msgretrynumber=?, status=? WHERE ackdata=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
||||
|
||||
def updateStatusForRerequestPubKey(t):
|
||||
shared.sqlSubmitQueue.put(
|
||||
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''')
|
||||
shared.sqlSubmitQueue.put(t)
|
||||
shared.sqlReturnQueue.get()
|
||||
shared.sqlSubmitQueue.put('commit')
|
Reference in New Issue
Block a user