add prefix_neighbors_count to routing table debug api

This commit is contained in:
Victor Shyba 2021-12-03 14:52:30 -03:00
parent 71b5c4c6ad
commit 2ab78a92ca

View file

@ -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