diff --git a/lbrynet/daemon/Components.py b/lbrynet/daemon/Components.py index 8b33e4909..6dee54317 100644 --- a/lbrynet/daemon/Components.py +++ b/lbrynet/daemon/Components.py @@ -360,6 +360,16 @@ class BlobComponent(Component): def stop(self): return self.blob_manager.stop() + @defer.inlineCallbacks + def get_status(self): + if not self.blob_manager: + count = 0 + else: + count = yield self.blob_manager.storage.count_finished_blobs() + defer.returnValue({ + 'finished_blobs': count + }) + class DHTComponent(Component): component_name = DHT_COMPONENT @@ -432,6 +442,11 @@ class HashAnnouncerComponent(Component): def stop(self): yield self.hash_announcer.stop() + def get_status(self): + return { + 'announce_queue_size': 0 if not self.hash_announcer else len(self.hash_announcer.hash_queue) + } + class RateLimiterComponent(Component): component_name = RATE_LIMITER_COMPONENT @@ -523,7 +538,7 @@ class FileManagerComponent(Component): if not self.file_manager: return return { - 'managed_streams': len(self.file_manager.lbry_files) + 'managed_files': len(self.file_manager.lbry_files) } @defer.inlineCallbacks diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 4cd73469d..677839aa9 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -90,7 +90,7 @@ class IterableContainer(object): class Checker(object): """The looping calls the daemon runs""" - INTERNET_CONNECTION = 'internet_connection_checker', 3600 + INTERNET_CONNECTION = 'internet_connection_checker', 300 # CONNECTION_STATUS = 'connection_status_checker' @@ -659,15 +659,12 @@ class Daemon(AuthJSONRPCServer): ############################################################################ @defer.inlineCallbacks - def jsonrpc_status(self, session_status=False): + def jsonrpc_status(self): """ Get daemon status Usage: - status [--session_status] - - Options: - --session_status : (bool) include session status in results + status Returns: (dict) lbrynet-daemon status @@ -684,6 +681,8 @@ class Daemon(AuthJSONRPCServer): 'hash_announcer': (bool), 'stream_identifier': (bool), 'file_manager': (bool), + 'blob_manager': (bool), + 'blockchain_headers': (bool), 'peer_protocol_server': (bool), 'reflector': (bool), 'upnp': (bool), @@ -693,27 +692,33 @@ class Daemon(AuthJSONRPCServer): 'code': (str) connection status code, 'message': (str) connection status message }, - 'blockchain_status': { + 'blockchain_headers': { + 'downloading_headers': (bool), + 'download_progress': (float) 0-100.0 + }, + 'wallet': { 'blocks': (int) local blockchain height, 'blocks_behind': (int) remote_height - local_height, 'best_blockhash': (str) block hash of most recent block, + 'is_encrypted': (bool) }, 'dht': { 'node_id': (str) lbry dht node id - hex encoded, 'peers_in_routing_table': (int) the number of peers in the routing table, }, - 'wallet_is_encrypted': (bool), - If given the session status option: - 'session_status': { - 'managed_blobs': (int) count of blobs in the blob manager, - 'managed_streams': (int) count of streams in the file manager, - 'announce_queue_size': (int) number of blobs currently queued to be announced, - 'should_announce_blobs': (int) number of blobs that should be announced, - } + 'blob_manager': { + 'finished_blobs': (int) number of finished blobs in the blob manager, + }, + 'hash_announcer': { + 'announce_queue_size': (int) number of blobs currently queued to be announced + }, + 'file_manager': { + 'managed_files': (int) count of files in the file manager, + } } """ - connection_code = CONNECTION_STATUS_CONNECTED if utils.check_connection() else CONNECTION_STATUS_NETWORK + connection_code = CONNECTION_STATUS_CONNECTED if self.connected_to_internet else CONNECTION_STATUS_NETWORK response = { 'installation_id': conf.settings.installation_id, 'is_running': all(self.component_manager.get_components_status().values()), @@ -729,7 +734,6 @@ class Daemon(AuthJSONRPCServer): status = yield defer.maybeDeferred(component.get_status) if status: response[component.component_name] = status - defer.returnValue(response) def jsonrpc_version(self): diff --git a/lbrynet/database/storage.py b/lbrynet/database/storage.py index 4da53f2ce..ffd3bb684 100644 --- a/lbrynet/database/storage.py +++ b/lbrynet/database/storage.py @@ -261,6 +261,11 @@ class SQLiteStorage(object): ) defer.returnValue([blob_hash.decode('hex') for blob_hash in blob_hashes]) + def count_finished_blobs(self): + return self.run_and_return_one_or_none( + "select count(*) from blob where status='finished'" + ) + def update_last_announced_blob(self, blob_hash, last_announced): return self.db.runOperation( "update blob set next_announce_time=?, last_announced_time=?, single_announce=0 where blob_hash=?",