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:
parent
ce0af77aa9
commit
4f7885e499
1 changed files with 6 additions and 0 deletions
|
@ -201,6 +201,12 @@ class Node(object):
|
||||||
print " %s:%i" % (contact.address, contact.port)
|
print " %s:%i" % (contact.address, contact.port)
|
||||||
print '=================================='
|
print '=================================='
|
||||||
|
|
||||||
|
def hasContacts(self):
|
||||||
|
for bucket in self._routingTable._buckets:
|
||||||
|
if bucket._contacts:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def getApproximateTotalDHTNodes(self):
|
def getApproximateTotalDHTNodes(self):
|
||||||
# get the deepest bucket and the number of contacts in that bucket and multiply it
|
# 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
|
# by the number of equivalently deep buckets in the whole DHT to get a really bad
|
||||||
|
|
Loading…
Reference in a new issue