Merge pull request #13 from SkyZH/patch-1

Clean up midpoint calculation in routing table.
This commit is contained in:
Brian Muller 2015-10-16 12:03:18 -04:00
commit b9b23e1131

View File

@ -21,7 +21,7 @@ class KBucket(object):
return self.nodes.values() return self.nodes.values()
def split(self): def split(self):
midpoint = self.range[1] - ((self.range[1] - self.range[0]) / 2) midpoint = (self.range[0] + self.range[1]) / 2
one = KBucket(self.range[0], midpoint, self.ksize) one = KBucket(self.range[0], midpoint, self.ksize)
two = KBucket(midpoint + 1, self.range[1], self.ksize) two = KBucket(midpoint + 1, self.range[1], self.ksize)
for node in self.nodes.values(): for node in self.nodes.values():