Merge branch 'fast-blob-completed'

This commit is contained in:
Jack Robison 2017-08-10 15:03:18 -04:00
commit c622cf13f0
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
2 changed files with 7 additions and 6 deletions

View file

@ -18,7 +18,7 @@ at anytime.
* Added configuration options for auto re-reflect * Added configuration options for auto re-reflect
### Fixed ### Fixed
* * Fixed reflector server blocking the `received_blob` reply on the server announcing the blob to the dht
* *
* Fixed incorrect formatting of "amount" fields * Fixed incorrect formatting of "amount" fields
* Fixed handling of SIGINT, SIGTERM. * Fixed handling of SIGINT, SIGTERM.

View file

@ -3,7 +3,7 @@ import os
import time import time
import sqlite3 import sqlite3
from twisted.internet import threads, defer from twisted.internet import threads, defer, reactor
from twisted.enterprise import adbapi from twisted.enterprise import adbapi
from lbrynet.core.HashBlob import BlobFile, BlobFileCreator from lbrynet.core.HashBlob import BlobFile, BlobFileCreator
from lbrynet.core.server.DHTHashAnnouncer import DHTHashSupplier from lbrynet.core.server.DHTHashAnnouncer import DHTHashSupplier
@ -11,6 +11,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class DiskBlobManager(DHTHashSupplier): class DiskBlobManager(DHTHashSupplier):
"""This class stores blobs on the hard disk""" """This class stores blobs on the hard disk"""
def __init__(self, hash_announcer, blob_dir, db_dir): def __init__(self, hash_announcer, blob_dir, db_dir):
@ -25,7 +26,6 @@ class DiskBlobManager(DHTHashSupplier):
self.blobs = {} self.blobs = {}
self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)} self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)}
@defer.inlineCallbacks @defer.inlineCallbacks
def setup(self): def setup(self):
log.info("Starting disk blob manager. blob_dir: %s, db_file: %s", str(self.blob_dir), 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): def _immediate_announce(self, blob_hashes):
if self.hash_announcer: if self.hash_announcer:
return self.hash_announcer.immediate_announce(blob_hashes) 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): def blob_completed(self, blob, next_announce_time=None):
if next_announce_time is None: if next_announce_time is None:
next_announce_time = self.get_next_announce_time() next_announce_time = self.get_next_announce_time()
d = self._add_completed_blob(blob.blob_hash, blob.length, next_announce_time) yield self._add_completed_blob(blob.blob_hash, blob.length, next_announce_time)
d.addCallback(lambda _: self._immediate_announce([blob.blob_hash])) reactor.callLater(0, self._immediate_announce, [blob.blob_hash])
return d
def completed_blobs(self, blobhashes_to_check): def completed_blobs(self, blobhashes_to_check):
return self._completed_blobs(blobhashes_to_check) return self._completed_blobs(blobhashes_to_check)