From 5cb4c06d0cb649caa00ac684953d5345e4ae1595 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 3 Dec 2021 14:52:30 -0300 Subject: [PATCH] add prefix_neighbors_count to routing table debug api --- lbry/extras/daemon/daemon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index c67a5b7e4..195564c54 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -5149,10 +5149,12 @@ class Daemon(metaclass=JSONRPCServerType): ] }, "node_id": (str) the local dht node id + "prefix_neighbors_count": (int) the amount of peers sharing the same byte prefix of the local node id } """ result = { - 'buckets': {} + 'buckets': {}, + 'prefix_neighbors_count': 0 } for i, _ in enumerate(self.dht_node.protocol.routing_table.buckets): @@ -5165,6 +5167,7 @@ class Daemon(metaclass=JSONRPCServerType): "node_id": hexlify(peer.node_id).decode(), } result['buckets'][i].append(host) + result['prefix_neighbors_count'] += 1 if peer.node_id[0] == self.dht_node.protocol.node_id[0] else 0 result['node_id'] = hexlify(self.dht_node.protocol.node_id).decode() return result