Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/class_singleCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def resendPubkeyRequest(self, address):
'Doing work necessary to again attempt to request a public key...'
))
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE toaddress=?''',
'''UPDATE sent SET status='msgqueued' WHERE toaddress=? AND folder='sent' ''',
address)
queues.workerQueue.put(('sendmessage', ''))

Expand All @@ -190,7 +190,7 @@ def resendMsg(self, ackdata):
' to our msg. Sending again.'
)
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE ackdata=?''',
'''UPDATE sent SET status='msgqueued' WHERE ackdata=? AND folder='sent' ''',
ackdata)
queues.workerQueue.put(('sendmessage', ''))
queues.UISignalQueue.put((
Expand Down
52 changes: 29 additions & 23 deletions src/class_singleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def run(self):

# Initialize the state.ackdataForWhichImWatching data structure
queryreturn = sqlQuery(
'''SELECT ackdata FROM sent WHERE status = 'msgsent' ''')
'''SELECT ackdata FROM sent WHERE status = 'msgsent' AND folder = 'sent' ''')
for row in queryreturn:
ackdata, = row
self.logger.info('Watching for ackdata %s', hexlify(ackdata))
Expand All @@ -109,7 +109,7 @@ def run(self):
newack = '\x00\x00\x00\x02\x01\x01' + oldack
state.ackdataForWhichImWatching[newack] = 0
sqlExecute(
'UPDATE sent SET ackdata=? WHERE ackdata=?',
'''UPDATE sent SET ackdata=? WHERE ackdata=? AND folder = 'sent' ''',
newack, oldack
)
del state.ackdataForWhichImWatching[oldack]
Expand Down Expand Up @@ -522,7 +522,7 @@ def sendBroadcast(self):
sqlExecute(
'''UPDATE sent SET status='broadcastqueued' '''

'''WHERE status = 'doingbroadcastpow' ''')
'''WHERE status = 'doingbroadcastpow' AND folder = 'sent' ''')
queryreturn = sqlQuery(
'''SELECT fromaddress, subject, message, '''
''' ackdata, ttl, encodingtype FROM sent '''
Expand Down Expand Up @@ -556,10 +556,12 @@ def sendBroadcast(self):
))
continue

sqlExecute(
'''UPDATE sent SET status='doingbroadcastpow' '''
''' WHERE ackdata=? AND status='broadcastqueued' ''',
ackdata)
if not sqlExecute(
'''UPDATE sent SET status='doingbroadcastpow' '''
''' WHERE ackdata=? AND status='broadcastqueued' '''
''' AND folder='sent' ''',
ackdata):
continue

# At this time these pubkeys are 65 bytes long
# because they include the encoding byte which we won't
Expand Down Expand Up @@ -680,8 +682,8 @@ def sendBroadcast(self):
# Update the status of the message in the 'sent' table to have
# a 'broadcastsent' status
sqlExecute(
'UPDATE sent SET msgid=?, status=?, lastactiontime=?'
' WHERE ackdata=?',
'''UPDATE sent SET msgid=?, status=?, lastactiontime=? '''
''' WHERE ackdata=? AND folder='sent' ''',
inventoryHash, 'broadcastsent', int(time.time()), ackdata
)

Expand All @@ -691,7 +693,8 @@ def sendMsg(self):
# Reset just in case
sqlExecute(
'''UPDATE sent SET status='msgqueued' '''
''' WHERE status IN ('doingpubkeypow', 'doingmsgpow')''')
''' WHERE status IN ('doingpubkeypow', 'doingmsgpow') '''
''' AND folder='sent' ''')
queryreturn = sqlQuery(
'''SELECT toaddress, fromaddress, subject, message, '''
''' ackdata, status, ttl, retrynumber, encodingtype FROM '''
Expand Down Expand Up @@ -727,11 +730,12 @@ def sendMsg(self):
# we can calculate the needed pubkey using the private keys
# in our keys.dat file.
elif BMConfigParser().has_section(toaddress):
sqlExecute(
if not sqlExecute(
'''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' ''',
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
toaddress
)
):
continue
status = 'doingmsgpow'
elif status == 'msgqueued':
# Let's see if we already have the pubkey in our pubkeys table
Expand All @@ -742,11 +746,12 @@ def sendMsg(self):
# If we have the needed pubkey in the pubkey table already,
if queryreturn != []:
# set the status of this msg to doingmsgpow
sqlExecute(
if not sqlExecute(
'''UPDATE sent SET status='doingmsgpow' '''
''' WHERE toaddress=? AND status='msgqueued' ''',
''' WHERE toaddress=? AND status='msgqueued' AND folder='sent' ''',
toaddress
)
):
continue
status = 'doingmsgpow'
# mark the pubkey as 'usedpersonally' so that
# we don't delete it later. If the pubkey version
Expand Down Expand Up @@ -829,7 +834,8 @@ def sendMsg(self):
''' toaddress=? AND '''
''' (status='msgqueued' or '''
''' status='awaitingpubkey' or '''
''' status='doingpubkeypow')''',
''' status='doingpubkeypow') AND '''
''' folder='sent' ''',
toaddress)
del state.neededPubkeys[tag]
break
Expand All @@ -846,7 +852,7 @@ def sendMsg(self):
sqlExecute(
'''UPDATE sent SET '''
''' status='doingpubkeypow' WHERE '''
''' toaddress=? AND status='msgqueued' ''',
''' toaddress=? AND status='msgqueued' AND folder='sent' ''',
toaddress
)
queues.UISignalQueue.put((
Expand Down Expand Up @@ -1039,7 +1045,7 @@ def sendMsg(self):
# we are willing to do.
sqlExecute(
'''UPDATE sent SET status='toodifficult' '''
''' WHERE ackdata=? ''',
''' WHERE ackdata=? AND folder='sent' ''',
ackdata)
queues.UISignalQueue.put((
'updateSentItemStatusByAckdata', (
Expand Down Expand Up @@ -1187,7 +1193,7 @@ def sendMsg(self):
)
except:
sqlExecute(
'''UPDATE sent SET status='badkey' WHERE ackdata=?''',
'''UPDATE sent SET status='badkey' WHERE ackdata=? AND folder='sent' ''',
ackdata
)
queues.UISignalQueue.put((
Expand Down Expand Up @@ -1294,7 +1300,7 @@ def sendMsg(self):
sleepTill = int(time.time() + TTL * 1.1)
sqlExecute(
'''UPDATE sent SET msgid=?, status=?, retrynumber=?, '''
''' sleeptill=?, lastactiontime=? WHERE ackdata=?''',
''' sleeptill=?, lastactiontime=? WHERE ackdata=? AND folder='sent' ''',
inventoryHash, newStatus, retryNumber + 1,
sleepTill, int(time.time()), ackdata
)
Expand Down Expand Up @@ -1340,7 +1346,7 @@ def requestPubKey(self, toAddress):
queryReturn = sqlQuery(
'''SELECT retrynumber FROM sent WHERE toaddress=? '''
''' AND (status='doingpubkeypow' OR status='awaitingpubkey') '''
''' LIMIT 1''',
''' AND folder='sent' LIMIT 1''',
toAddress
)
if not queryReturn:
Expand Down Expand Up @@ -1426,7 +1432,7 @@ def requestPubKey(self, toAddress):
'''UPDATE sent SET lastactiontime=?, '''
''' status='awaitingpubkey', retrynumber=?, sleeptill=? '''
''' WHERE toaddress=? AND (status='doingpubkeypow' OR '''
''' status='awaitingpubkey') ''',
''' status='awaitingpubkey') AND folder='sent' ''',
int(time.time()), retryNumber + 1, sleeptill, toAddress)

queues.UISignalQueue.put((
Expand Down