From e4197704c63a6112a84f61a2238b24a483dcc055 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Fri, 12 Apr 2013 15:31:45 -0400 Subject: [PATCH] store pubkeys in inventory longer --- bitmessagemain.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bitmessagemain.py b/bitmessagemain.py index e9ce1b41..71af5982 100755 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -455,8 +455,8 @@ class receiveDataThread(QThread): self.receivedgetbiginv = True sqlLock.acquire() #Select all hashes which are younger than two days old and in this stream. - t = (int(time.time())-maximumAgeOfObjectsThatIAdvertiseToOthers,self.streamNumber) - sqlSubmitQueue.put('''SELECT hash FROM inventory WHERE receivedtime>? and streamnumber=?''') + t = (int(time.time())-maximumAgeOfObjectsThatIAdvertiseToOthers,int(time.time())-lengthOfTimeToHoldOnToAllPubkeys,self.streamNumber) + sqlSubmitQueue.put('''SELECT hash FROM inventory WHERE ((receivedtime>? and objecttype<>'pubkey') or (receivedtime>? and objecttype='pubkey')) and streamnumber=?''') sqlSubmitQueue.put(t) queryreturn = sqlReturnQueue.get() sqlLock.release() @@ -1024,7 +1024,7 @@ class receiveDataThread(QThread): readPosition = 8 #for the nonce embeddedTime, = unpack('>I',data[readPosition:readPosition+4]) - if embeddedTime < int(time.time())-lengthOfTimeToHoldOnToAllPubkeys-86400: #If the pubkey is more than a month old then reject it. (the 86400 is included to give an extra day of wiggle-room. If the wiggle-room is actually of any use, everyone on the network will delete this pubkey from their database the next time the cleanerThread cleans anyway- except for the node that actually wants the pubkey.) + if embeddedTime < int(time.time())-lengthOfTimeToHoldOnToAllPubkeys: printLock.acquire() print 'The embedded time in this pubkey message is too old. Ignoring. Embedded time is:', embeddedTime printLock.release() @@ -1054,7 +1054,7 @@ class receiveDataThread(QThread): inventoryLock.release() return objectType = 'pubkey' - inventory[inventoryHash] = (objectType, self.streamNumber, data, int(time.time())) + inventory[inventoryHash] = (objectType, self.streamNumber, data, embeddedTime) inventoryLock.release() self.broadcastinv(inventoryHash) self.emit(SIGNAL("incrementNumberOfPubkeysProcessed()")) @@ -2074,8 +2074,8 @@ class singleCleaner(QThread): #inventory (moves data from the inventory data structure to the on-disk sql database) sqlLock.acquire() #inventory (clears data more than 2 days and 12 hours old) - t = (int(time.time())-lengthOfTimeToLeaveObjectsInInventory,) - sqlSubmitQueue.put('''DELETE FROM inventory WHERE receivedtime'pubkey') OR (receivedtime