add blob announcement information to session_status

This commit is contained in:
Kay Kurokawa 2017-10-05 13:59:27 -04:00
parent be78390793
commit 1f839fe2a6
No known key found for this signature in database
GPG key ID: 2D65FB1698958B8D
2 changed files with 15 additions and 0 deletions

View file

@ -88,6 +88,9 @@ class DiskBlobManager(DHTHashSupplier):
def hashes_to_announce(self):
return self._get_blobs_to_announce()
def count_should_announce_blobs(self):
return self._count_should_announce_blobs()
def set_should_announce(self, blob_hash, should_announce):
if blob_hash in self.blobs:
blob = self.blobs[blob_hash]
@ -215,6 +218,12 @@ class DiskBlobManager(DHTHashSupplier):
(blob_hash,))
defer.returnValue(result[0][0])
@rerun_if_locked
@defer.inlineCallbacks
def _count_should_announce_blobs(self):
result = yield self.db_conn.runQuery("select count(*) from blobs where should_announce=1")
defer.returnValue(result[0][0])
@defer.inlineCallbacks
def _completed_blobs(self, blobhashes_to_check):
"""Returns of the blobhashes_to_check, which are valid"""

View file

@ -1029,6 +1029,8 @@ class Daemon(AuthJSONRPCServer):
'session_status': {
'managed_blobs': count of blobs in the blob manager,
'managed_streams': count of streams in the file manager
'announce_queue_size': number of blobs currently queued to be announced
'should_announce_blobs': number of blobs that should be announced
}
If given the dht status option:
@ -1077,9 +1079,13 @@ class Daemon(AuthJSONRPCServer):
}
if session_status:
blobs = yield self.session.blob_manager.get_all_verified_blobs()
announce_queue_size = self.session.hash_announcer.hash_queue_size()
should_announce_blobs = yield self.session.blob_manager.count_should_announce_blobs()
response['session_status'] = {
'managed_blobs': len(blobs),
'managed_streams': len(self.lbry_file_manager.lbry_files),
'announce_queue_size': announce_queue_size,
'should_announce_blobs': should_announce_blobs,
}
if dht_status:
response['dht_status'] = self.session.dht_node.get_bandwidth_stats()