Retransmit timing changes

- makes it behave more like in the description
- partial for #847
This commit is contained in:
Peter Šurda 2017-02-25 23:40:37 +01:00
parent 7ef91bd607
commit 74c85b4a9e
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -609,10 +609,8 @@ class singleWorker(threading.Thread, StoppableThread):
# At this point we know that we have the necessary pubkey in the pubkeys table. # At this point we know that we have the necessary pubkey in the pubkeys table.
if retryNumber == 0: TTL *= 2**retryNumber
if TTL > 28 * 24 * 60 * 60: if TTL > 28 * 24 * 60 * 60:
TTL = 28 * 24 * 60 * 60
else:
TTL = 28 * 24 * 60 * 60 TTL = 28 * 24 * 60 * 60
TTL = int(TTL + random.randrange(-300, 300))# add some randomness to the TTL TTL = int(TTL + random.randrange(-300, 300))# add some randomness to the TTL
embeddedTime = int(time.time() + TTL) embeddedTime = int(time.time() + TTL)
@ -834,10 +832,8 @@ class singleWorker(threading.Thread, StoppableThread):
newStatus = 'msgsentnoackexpected' newStatus = 'msgsentnoackexpected'
else: else:
newStatus = 'msgsent' newStatus = 'msgsent'
if retryNumber == 0: # wait 10% past expiration
sleepTill = int(time.time()) + TTL sleepTill = int(time.time() + TTL * 1.1)
else:
sleepTill = int(time.time()) + 28*24*60*60 * 2**retryNumber
sqlExecute('''UPDATE sent SET msgid=?, status=?, retrynumber=?, sleeptill=?, lastactiontime=? WHERE ackdata=?''', sqlExecute('''UPDATE sent SET msgid=?, status=?, retrynumber=?, sleeptill=?, lastactiontime=? WHERE ackdata=?''',
inventoryHash, inventoryHash,
newStatus, newStatus,
@ -896,9 +892,9 @@ class singleWorker(threading.Thread, StoppableThread):
if tag not in state.neededPubkeys: if tag not in state.neededPubkeys:
state.neededPubkeys[tag] = (toAddress, highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))) # We'll need this for when we receive a pubkey reply: it will be encrypted and we'll need to decrypt it. state.neededPubkeys[tag] = (toAddress, highlevelcrypto.makeCryptor(hexlify(privEncryptionKey))) # We'll need this for when we receive a pubkey reply: it will be encrypted and we'll need to decrypt it.
if retryNumber == 0: TTL = 2.5*24*60*60 # 2.5 days. This was chosen fairly arbitrarily.
TTL = 2.5*24*60*60 # 2.5 days. This was chosen fairly arbitrarily. TTL *= 2**retryNumber
else: if TTL > 28*24*60*60:
TTL = 28*24*60*60 TTL = 28*24*60*60
TTL = TTL + random.randrange(-300, 300) # add some randomness to the TTL TTL = TTL + random.randrange(-300, 300) # add some randomness to the TTL
embeddedTime = int(time.time() + TTL) embeddedTime = int(time.time() + TTL)
@ -934,10 +930,8 @@ class singleWorker(threading.Thread, StoppableThread):
protocol.broadcastToSendDataQueues(( protocol.broadcastToSendDataQueues((
streamNumber, 'advertiseobject', inventoryHash)) streamNumber, 'advertiseobject', inventoryHash))
if retryNumber == 0: # wait 10% past expiration
sleeptill = int(time.time()) + TTL sleeptill = int(time.time() + TTL * 1.1)
else:
sleeptill = int(time.time()) + 28*24*60*60 * 2**retryNumber
sqlExecute( sqlExecute(
'''UPDATE sent SET lastactiontime=?, status='awaitingpubkey', retrynumber=?, sleeptill=? WHERE toaddress=? AND (status='doingpubkeypow' OR status='awaitingpubkey') ''', '''UPDATE sent SET lastactiontime=?, status='awaitingpubkey', retrynumber=?, sleeptill=? WHERE toaddress=? AND (status='doingpubkeypow' OR status='awaitingpubkey') ''',
int(time.time()), int(time.time()),