From 9d272befcdbaf4506df03407aa16aa2ba3647888 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 20:28:16 -0500 Subject: [PATCH 1/3] Convert length of shortened plaintext LBRY ID to constant --- lbrynet/lbrynet_daemon/Daemon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index ed9198482..e9cccef0d 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -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""" @@ -586,7 +586,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: From 4cb2a8f2aa25672268dbb458934f17065d3afc05 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 20:28:49 -0500 Subject: [PATCH 2/3] Include LBRY ID in version() API method result --- lbrynet/lbrynet_daemon/Daemon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index e9cccef0d..65896722f 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1168,6 +1168,7 @@ class Daemon(AuthJSONRPCServer): 'lbrynet_version': lbrynet_version, 'lbryum_version': lbryum_version, 'ui_version': self.ui_version, + 'lbry_id': base58.b58encode(self.lbryid)[:SHORT_LBRY_ID_LEN], 'remote_lbrynet': self.git_lbrynet_version, 'remote_lbryum': self.git_lbryum_version, 'lbrynet_update_available': lbrynet_update_available, From a6326ee7a184ab1cdf4618f33a242c70e754440b Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 28 Nov 2016 14:16:21 -0500 Subject: [PATCH 3/3] get_lbry_session_info --- lbrynet/lbrynet_daemon/Daemon.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 65896722f..0394dc37b 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -1168,7 +1168,6 @@ class Daemon(AuthJSONRPCServer): 'lbrynet_version': lbrynet_version, 'lbryum_version': lbryum_version, 'ui_version': self.ui_version, - 'lbry_id': base58.b58encode(self.lbryid)[:SHORT_LBRY_ID_LEN], 'remote_lbrynet': self.git_lbrynet_version, 'remote_lbryum': self.git_lbryum_version, 'lbrynet_update_available': lbrynet_update_available, @@ -1178,6 +1177,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