Commit 485d4aa8 authored by Jim Posen's avatar Jim Posen Committed by Marek Kotewicz
Browse files

Fix XOR distance calculation in discovery Kademlia impl (#8589)

* network-devp2p: Test for discovery bucket insertion.

All test values are randomly generated and the assertions are checked manually.
Test fails because distance metric is implemented incorrectly.

* network-devp2p: Fix discovery distance function.

The Kademlia distance function (XOR) was implemented incorrectly as a population count.

* network-devp2p: Refactor nearest_node_entries to be on instance.

Optimizations are possible with more access to the discovery state.

* network-devp2p: Fix loss of precision in nearest_node_entries.

* network-devp2p: More efficient nearest node search.

The discovery algorithm to identify the nearest k nodes does not need to scan
all entries in all buckets.
parent 799ae29a
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment