From 4e05eac8540a9c41e7f6ee5d41cab3ce54129c41 Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Fri, 21 Jul 2017 14:05:08 -0400 Subject: [PATCH 1/2] add blob_announce API command, to eventually replace blob_announce_all --- lbrynet/daemon/Daemon.py | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 7b1d0b964..e5223e768 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2351,6 +2351,53 @@ class Daemon(AuthJSONRPCServer): d.addCallback(lambda r: self._render_response(r)) return d + @defer.inlineCallbacks + @AuthJSONRPCServer.flags(announce_all="-a") + def jsonrpc_blob_announce(self, announce_all=None, blob_hash=None, + stream_hash=None, sd_hash=None): + """ + Announce blobs to the DHT + + Usage: + blob_announce [-a] [ | --blob_hash=] + [ | --stream_hash=] + [ | --sd_hash=] + + Options: + -a : announce all the blobs possessed by user + , --blob_hash= : announce a blob, specified by blob_hash + , --stream_hash= : announce all blobs associated with + stream_hash + , --sd_hash= : announce all blobs associated with + sd_hash and the sd_hash itself + + Returns: + (bool) true if successful + """ + if announce_all: + yield self.session.blob_manager.immediate_announce_all_blobs() + elif blob_hash: + blob_hashes = [blob_hash] + yield self.session.blob_manager._immediate_announce(blob_hashes) + elif stream_hash: + blobs = yield self.get_blobs_for_stream_hash(stream_hash) + blobs = [blob for blob in blobs if blob.is_validated()] + blob_hashes = [blob.blob_hash for blob in blobs] + yield self.session.blob_manager._immediate_announce(blob_hashes) + elif sd_hash: + blobs = yield self.get_blobs_for_sd_hash(sd_hash) + blobs = [blob for blob in blobs if blob.is_validated()] + blob_hashes = [blob.blob_hash for blob in blobs] + blob_hashes.append(sd_hash) + yield self.session.blob_manager._immediate_announce(blob_hashes) + else: + raise Exception('single argument must be specified') + + + response = yield self._render_response(True) + defer.returnValue(response) + + # TODO: This command should be deprecated in favor of blob_announce def jsonrpc_blob_announce_all(self): """ Announce all blobs to the DHT From 999d223241ffa9d4e7bba85150596c499411266f Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Mon, 31 Jul 2017 10:44:01 -0400 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f829d91..dec16c564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ at anytime. ### Added * Added validation of currencies. - * + * Added blob_announce API command ### Fixed *