Merge pull request #287 from lbryio/version-add-lbry-id

get_lbry_session_info
This commit is contained in:
Jack Robison 2016-11-28 14:26:43 -05:00 committed by GitHub
commit 48b137fe4c

View file

@ -96,7 +96,7 @@ NOT_FOUND = 404
OK_CODE = 200
PENDING_LBRY_ID = "not set"
SHORT_LBRY_ID_LEN = 20
class Checker:
"""The looping calls the daemon runs"""
@ -592,7 +592,7 @@ class Daemon(AuthJSONRPCServer):
def _upload_log(self, log_type=None, exclude_previous=False, force=False):
if self.upload_log or force:
if self.lbryid is not PENDING_LBRY_ID:
id_hash = base58.b58encode(self.lbryid)[:20]
id_hash = base58.b58encode(self.lbryid)[:SHORT_LBRY_ID_LEN]
else:
id_hash = self.lbryid
try:
@ -1182,6 +1182,32 @@ class Daemon(AuthJSONRPCServer):
log.info("Get version info: " + json.dumps(msg))
return self._render_response(msg, OK_CODE)
def jsonrpc_get_lbry_session_info(self):
"""
Get information about the current lbrynet session
Args:
None
Returns:
'lbry_id': string,
'managed_blobs': int, number of completed blobs in the blob manager,
'managed_streams': int, number of lbry files in the file manager
"""
d = self.session.blob_manager.get_all_verified_blobs()
def _prepare_message(blobs):
msg = {
'lbry_id': base58.b58encode(self.lbryid)[:SHORT_LBRY_ID_LEN],
'managed_blobs': len(blobs),
'managed_streams': len(self.lbry_file_manager.lbry_files),
}
return msg
d.addCallback(_prepare_message)
d.addCallback(lambda r: self._render_response(r, OK_CODE))
return d
def jsonrpc_get_settings(self):
"""
Get lbrynet daemon settings