add get_all_verified_blobs

This commit is contained in:
Jack 2016-08-26 00:32:33 -04:00
parent 47fae977dd
commit 710e549c03
2 changed files with 21 additions and 4 deletions

View file

@ -67,6 +67,9 @@ class BlobManager(DHTHashSupplier):
def blob_paid_for(self, blob_hash, amount):
pass
def get_all_verified_blobs(self):
pass
class DiskBlobManager(BlobManager):
"""This class stores blobs on the hard disk"""
@ -177,6 +180,11 @@ class DiskBlobManager(BlobManager):
def check_consistency(self):
return self._check_consistency()
def get_all_verified_blobs(self):
d = self._get_all_verified_blob_hashes()
d.addCallback(self.completed_blobs)
return d
def _manage(self):
from twisted.internet import reactor
@ -462,6 +470,10 @@ class TempBlobManager(BlobManager):
blobs = [b.blob_hash for b in self.blobs.itervalues() if b.blob_hash in blobs_to_check and b.is_validated()]
return defer.succeed(blobs)
def get_all_verified_blobs(self):
d = self.completed_blobs(self.blobs)
return d
def hashes_to_announce(self):
now = time.time()
blobs = [blob_hash for blob_hash, announce_time in self.blob_next_announces.iteritems() if announce_time < now]

View file

@ -2454,12 +2454,17 @@ class LBRYDaemon(jsonrpc.JSONRPC):
d.addCallbacks(lambda _: self._render_response(True, OK_CODE), lambda err: self._render_response(err.getTraceback(), OK_CODE))
return d
def jsonrpc_get_blobs(self):
def jsonrpc_get_blob_hashes(self):
"""
return all blobs
Returns all blob hashes
Args:
None
Returns:
list of blob hashes
"""
d = defer.succeed(self.session.blob_manager.blobs)
d = self.session.blob_manager.get_all_verified_blobs()
d.addCallback(lambda r: self._render_response(r, OK_CODE))
return d