mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-09-01 01:35:14 +00:00
Immediately announce completed blobs
It doesn't seem necessary to wait up to 60 seconds for a new blob to be announced to the dht. Immediately announce it and schedule the next announce time as usual.
This commit is contained in:
parent
fe4ea9b33a
commit
f796f701f2
2 changed files with 8 additions and 3 deletions
|
@ -120,6 +120,7 @@ class DiskBlobManager(BlobManager):
|
||||||
return self.blob_creator_type(self, self.blob_dir)
|
return self.blob_creator_type(self, self.blob_dir)
|
||||||
|
|
||||||
def _make_new_blob(self, blob_hash, upload_allowed, length=None):
|
def _make_new_blob(self, blob_hash, upload_allowed, length=None):
|
||||||
|
log.debug('Making a new blob for %s', blob_hash)
|
||||||
blob = self.blob_type(self.blob_dir, blob_hash, upload_allowed, length)
|
blob = self.blob_type(self.blob_dir, blob_hash, upload_allowed, length)
|
||||||
self.blobs[blob_hash] = blob
|
self.blobs[blob_hash] = blob
|
||||||
d = self._completed_blobs([blob_hash])
|
d = self._completed_blobs([blob_hash])
|
||||||
|
@ -143,9 +144,11 @@ class DiskBlobManager(BlobManager):
|
||||||
|
|
||||||
def blob_completed(self, blob, next_announce_time=None):
|
def blob_completed(self, blob, next_announce_time=None):
|
||||||
if next_announce_time is None:
|
if next_announce_time is None:
|
||||||
next_announce_time = time.time()
|
next_announce_time = time.time() + self.hash_reannounce_time
|
||||||
return self._add_completed_blob(blob.blob_hash, blob.length,
|
d = self._add_completed_blob(blob.blob_hash, blob.length,
|
||||||
time.time(), next_announce_time)
|
time.time(), next_announce_time)
|
||||||
|
d.addCallback(lambda _: self.hash_announcer.immediate_announce([blob.blob_hash]))
|
||||||
|
return d
|
||||||
|
|
||||||
def completed_blobs(self, blobs_to_check):
|
def completed_blobs(self, blobs_to_check):
|
||||||
return self._completed_blobs(blobs_to_check)
|
return self._completed_blobs(blobs_to_check)
|
||||||
|
|
|
@ -42,6 +42,7 @@ class DHTHashAnnouncer(object):
|
||||||
return defer.succeed(False)
|
return defer.succeed(False)
|
||||||
|
|
||||||
def _announce_available_hashes(self):
|
def _announce_available_hashes(self):
|
||||||
|
log.debug('Announcing available hashes')
|
||||||
ds = []
|
ds = []
|
||||||
for supplier in self.suppliers:
|
for supplier in self.suppliers:
|
||||||
d = supplier.hashes_to_announce()
|
d = supplier.hashes_to_announce()
|
||||||
|
@ -62,6 +63,7 @@ class DHTHashAnnouncer(object):
|
||||||
def announce():
|
def announce():
|
||||||
if len(self.hash_queue):
|
if len(self.hash_queue):
|
||||||
h, announce_deferred = self.hash_queue.popleft()
|
h, announce_deferred = self.hash_queue.popleft()
|
||||||
|
log.debug('Announcing blob %s to dht', h)
|
||||||
d = self.dht_node.announceHaveBlob(binascii.unhexlify(h), self.peer_port)
|
d = self.dht_node.announceHaveBlob(binascii.unhexlify(h), self.peer_port)
|
||||||
d.chainDeferred(announce_deferred)
|
d.chainDeferred(announce_deferred)
|
||||||
d.addBoth(lambda _: reactor.callLater(0, announce))
|
d.addBoth(lambda _: reactor.callLater(0, announce))
|
||||||
|
|
Loading…
Add table
Reference in a new issue