Download fixes

- don't expire too quickly
- ignore connections that haven't been fully established yet
This commit is contained in:
Peter Šurda 2018-02-01 12:48:14 +01:00
parent c5dc7fc903
commit 290b87a49f
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 2 additions and 3 deletions

View File

@ -38,7 +38,7 @@ class DownloadThread(threading.Thread, StoppableThread):
while not self._stopped:
requested = 0
# Choose downloading peers randomly
connections = BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values()
connections = [x for x in BMConnectionPool().inboundConnections.values() + BMConnectionPool().outboundConnections.values() if x.fullyEstablished]
random.shuffle(connections)
try:
requestChunk = max(int(min(DownloadThread.maxRequestChunk, len(missingObjects)) / len(connections)), 1)
@ -46,7 +46,6 @@ class DownloadThread(threading.Thread, StoppableThread):
requestChunk = 1
for i in connections:
now = time.time()
timedOut = now - DownloadThread.requestTimeout
try:
request = i.objectsNewToMe.randomKeys(requestChunk)
except KeyError:

View File

@ -85,7 +85,7 @@ class ObjectTracker(object):
if hashId in Dandelion().hashMap:
Dandelion().fluffTrigger(hashId)
if hashId not in missingObjects:
missingObjects[hashId] = True
missingObjects[hashId] = time.time()
self.objectsNewToMe[hashId] = True
def hasAddr(self, addr):