From 47fae977dd6ac3a70b0c1fbf26547b5448162902 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 25 Aug 2016 23:39:05 -0400 Subject: [PATCH 1/2] fix Access-Control-Allow-Origin problem --- lbrynet/lbrynet_daemon/LBRYDaemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 753aeb157..0f4f9b568 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -426,7 +426,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): except jsonrpclib.Fault, f: self._cbRender(f, request, id, version) else: - request.setHeader("Access-Control-Allow-Origin", "*") + request.setHeader("Access-Control-Allow-Origin", "localhost") request.setHeader("content-type", "text/json") if args == [{}]: d = defer.maybeDeferred(function) From 710e549c03437ad2b7ef04ab37ae6a1179594636 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 26 Aug 2016 00:32:33 -0400 Subject: [PATCH 2/2] add get_all_verified_blobs --- lbrynet/core/BlobManager.py | 14 +++++++++++++- lbrynet/lbrynet_daemon/LBRYDaemon.py | 11 ++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lbrynet/core/BlobManager.py b/lbrynet/core/BlobManager.py index f7bd7a4bc..fc37a3b7e 100644 --- a/lbrynet/core/BlobManager.py +++ b/lbrynet/core/BlobManager.py @@ -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""" @@ -78,7 +81,7 @@ class DiskBlobManager(BlobManager): self.blob_type = BlobFile self.blob_creator_type = BlobFileCreator self.blobs = {} - self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)} + self.blob_hashes_to_delete = {} # {blob_hash: being_deleted (True/False)} self._next_manage_call = None def setup(self): @@ -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] diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 0f4f9b568..ccb2df03b 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -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