forked from LBRYCommunity/lbry-sdk
don't block blob_completed on the blob being announced
this considerably slows down the rate at which reflector server can receive blobs
This commit is contained in:
parent
350386ba21
commit
09d336bd0c
1 changed files with 6 additions and 5 deletions
|
@ -3,7 +3,7 @@ import os
|
|||
import time
|
||||
import sqlite3
|
||||
|
||||
from twisted.internet import threads, defer
|
||||
from twisted.internet import threads, defer, reactor
|
||||
from twisted.enterprise import adbapi
|
||||
from lbrynet.core.HashBlob import BlobFile, BlobFileCreator
|
||||
from lbrynet.core.server.DHTHashAnnouncer import DHTHashSupplier
|
||||
|
@ -11,6 +11,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DiskBlobManager(DHTHashSupplier):
|
||||
"""This class stores blobs on the hard disk"""
|
||||
def __init__(self, hash_announcer, blob_dir, db_dir):
|
||||
|
@ -25,7 +26,6 @@ class DiskBlobManager(DHTHashSupplier):
|
|||
self.blobs = {}
|
||||
self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)}
|
||||
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def setup(self):
|
||||
log.info("Starting disk blob manager. blob_dir: %s, db_file: %s", str(self.blob_dir),
|
||||
|
@ -58,13 +58,14 @@ class DiskBlobManager(DHTHashSupplier):
|
|||
def _immediate_announce(self, blob_hashes):
|
||||
if self.hash_announcer:
|
||||
return self.hash_announcer.immediate_announce(blob_hashes)
|
||||
raise Exception("Hash announcer not set")
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def blob_completed(self, blob, next_announce_time=None):
|
||||
if next_announce_time is None:
|
||||
next_announce_time = self.get_next_announce_time()
|
||||
d = self._add_completed_blob(blob.blob_hash, blob.length, next_announce_time)
|
||||
d.addCallback(lambda _: self._immediate_announce([blob.blob_hash]))
|
||||
return d
|
||||
yield self._add_completed_blob(blob.blob_hash, blob.length, next_announce_time)
|
||||
reactor.callLater(0, self._immediate_announce, [blob.blob_hash])
|
||||
|
||||
def completed_blobs(self, blobhashes_to_check):
|
||||
return self._completed_blobs(blobhashes_to_check)
|
||||
|
|
Loading…
Reference in a new issue