Download fixes

- check if already have object before requesting
This commit is contained in:
Peter Šurda 2018-02-01 22:58:04 +01:00
parent dcce7ed4c5
commit 8498143783
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import time
import addresses
from debug import logger
from helper_threading import StoppableThread
from inventory import Inventory
from network.connectionpool import BMConnectionPool
import protocol
from state import missingObjects
@ -53,6 +54,9 @@ class DownloadThread(threading.Thread, StoppableThread):
payload = bytearray()
payload.extend(addresses.encodeVarint(len(request)))
for chunk in request:
if chunk in Inventory():
del i.objectsNewToMe[chunk]
continue
payload.extend(chunk)
missingObjects[chunk] = now
i.append_write_buf(protocol.CreatePacket('getdata', payload))