From a9e390126ced9638dafabbf757160687a6111844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E8=90=8C=E7=9A=84=E5=BC=9B=E5=93=A5SkyZH?= =?UTF-8?q?=E5=9C=A8=E9=93=B6=E5=85=89=E9=97=AA=E7=83=81=E7=9A=84=E6=B2=99?= =?UTF-8?q?=E6=BB=A9=E4=B8=8A=E9=9D=A2=E5=AF=B9=E5=A4=A7=E6=B5=B7=E5=86=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= Date: Fri, 16 Oct 2015 23:43:11 +0800 Subject: [PATCH 1/2] Update routing.py --- kademlia/routing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From ac7b3c12ab857a156c578b825d86cc45de1a3151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E8=90=8C=E7=9A=84=E5=BC=9B=E5=93=A5SkyZH?= =?UTF-8?q?=E5=9C=A8=E9=93=B6=E5=85=89=E9=97=AA=E7=83=81=E7=9A=84=E6=B2=99?= =?UTF-8?q?=E6=BB=A9=E4=B8=8A=E9=9D=A2=E5=AF=B9=E5=A4=A7=E6=B5=B7=E5=86=99?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= Date: Fri, 16 Oct 2015 23:49:54 +0800 Subject: [PATCH 2/2] Update routing.py --- kademlia/routing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kademlia/routing.py b/kademlia/routing.py index 21a418e..5bde1bf 100644 --- a/kademlia/routing.py +++ b/kademlia/routing.py @@ -25,7 +25,7 @@ class KBucket(object): 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.id <= midpoint else two + bucket = one if node.long_id <= midpoint else two bucket.nodes[node.id] = node return (one, two)