diff --git a/kademlia/routing.py b/kademlia/routing.py index a79a988..21a418e 100644 --- a/kademlia/routing.py +++ b/kademlia/routing.py @@ -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)