dht_node: add hasContacts method

This method can be used by other components to check
if in the Node routing table there is at least one peer.

Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
This commit is contained in:
Antonio Quartulli 2018-02-01 17:21:52 +08:00
parent ce0af77aa9
commit 4f7885e499
No known key found for this signature in database
GPG key ID: 07A53C580EF2CD74

View file

@ -201,6 +201,12 @@ class Node(object):
print " %s:%i" % (contact.address, contact.port)
print '=================================='
def hasContacts(self):
for bucket in self._routingTable._buckets:
if bucket._contacts:
return True
return False
def getApproximateTotalDHTNodes(self):
# get the deepest bucket and the number of contacts in that bucket and multiply it
# by the number of equivalently deep buckets in the whole DHT to get a really bad