Update routing.py

This commit is contained in:
呆萌的弛哥SkyZH在银光闪烁的沙滩上面对大海写代码 2015-10-16 23:43:11 +08:00
parent 00ecaf5e31
commit a9e390126c
1 changed files with 2 additions and 2 deletions

View File

@ -21,11 +21,11 @@ class KBucket(object):
return self.nodes.values()
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)
two = KBucket(midpoint + 1, self.range[1], self.ksize)
for node in self.nodes.values():
bucket = one if node.long_id <= midpoint else two
bucket = one if node.id <= midpoint else two
bucket.nodes[node.id] = node
return (one, two)