forked from LBRYCommunity/lbry-sdk
Merge pull request #793 from lbryio/blob_announce
Better blob announce API command
This commit is contained in:
commit
5ce360511b
2 changed files with 48 additions and 1 deletions
|
@ -14,7 +14,7 @@ at anytime.
|
|||
|
||||
### Added
|
||||
* Added validation of currencies.
|
||||
*
|
||||
* Added blob_announce API command
|
||||
|
||||
### Fixed
|
||||
* Fixed incorrect formatting of "amount" fields
|
||||
|
|
|
@ -2349,6 +2349,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> | --blob_hash=<blob_hash>]
|
||||
[<stream_hash> | --stream_hash=<stream_hash>]
|
||||
[<sd_hash> | --sd_hash=<sd_hash>]
|
||||
|
||||
Options:
|
||||
-a : announce all the blobs possessed by user
|
||||
<blob_hash>, --blob_hash=<blob_hash> : announce a blob, specified by blob_hash
|
||||
<stream_hash>, --stream_hash=<stream_hash> : announce all blobs associated with
|
||||
stream_hash
|
||||
<sd_hash>, --sd_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
|
||||
|
|
Loading…
Reference in a new issue