refactor peerinfo

This commit is contained in:
zixuanzh
2019-04-19 16:29:15 -04:00
parent c03f2f63d2
commit fb687dad09
4 changed files with 30 additions and 5 deletions

View File

@ -151,7 +151,11 @@ class RoutingTable:
self.buckets[index].remove_node(node)
def is_new_node(self, node):
print ("IN IS NEW NODE")
print (node)
print (self.buckets)
index = self.get_bucket_for(node)
print (index)
return self.buckets[index].is_new_node(node)
def add_contact(self, node):
@ -174,7 +178,15 @@ class RoutingTable:
"""
Get the index of the bucket that the given node would fall into.
"""
print ("IN GET BUKCKET FOR")
print (node)
print (node.long_id)
print (self.buckets)
for index, bucket in enumerate(self.buckets):
print ("IN ENUMERATE")
print (index)
print (bucket)
print (bucket.range)
if node.long_id < bucket.range[1]:
return index
# we should never be here, but make linter happy