Fix repeated downloads

- a bug in RandomTrackingDict caused requesting to download the same objects
  over and over
- the bug is that the lastObject wasn't properly initalised, this caused the
  write buffer to fill with "getdata" requests until the first object was
  received
- this PR should address both the excessive bandwidth as well as excessive CPU
  usage during downloading
This commit is contained in:
Peter Šurda 2019-01-01 21:18:05 +01:00
parent 7895e94365
commit c3939875d3
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -111,6 +111,7 @@ class RandomTrackingDict(object):
# or if last object received too long time ago
if self.pendingLen == self.len or self.lastObject + self.pendingTimeout > time():
self.pendingLen = 0
self.setLastObject()
available = self.len - self.pendingLen
if count > available:
count = available