mirror of https://github.com/bmuller/kademlia.git
Bug fix in NodeHeap
When running with a large number of nodes it fails to send the store request to the k closest nodes and instead ends up sending multiple store requests to the same 4 or 5 nodes. It appears the cause is a bug in NodeHeap which allows the same node to be pushed onto the heap multiple times bumping out other legimate nodes. This pull request just adds some logic to make sure the node isn't already in the heap before pushing.
This commit is contained in:
parent
d222050025
commit
088699bfbb
|
@ -94,6 +94,7 @@ class NodeHeap(object):
|
||||||
nodes = [nodes]
|
nodes = [nodes]
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
if node.id not in [n.id for n in self]:
|
||||||
distance = self.node.distanceTo(node)
|
distance = self.node.distanceTo(node)
|
||||||
heapq.heappush(self.heap, (distance, node))
|
heapq.heappush(self.heap, (distance, node))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue