This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Distance between nodes in node discovery #8721
Labels
F3-annoyance 💩
The client behaves within expectations, however this “expected behaviour” itself is at issue.
M4-core ⛓
Core client code / Rust.
P5-sometimesoon 🌲
Issue is worth doing soon.
Milestone
https://github.com/paritytech/parity/blob/master/util/network-devp2p/src/discovery.rs#L236
It looks like the distance between nodes is calculated as a common prefix of each byte. Shouldn't it be just a common binary prefix?
I wrote a test
1_000_000_000
-[0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
9_000_000_000
-[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
So the common prefix is 2.
Discovery::distance
returns 24The text was updated successfully, but these errors were encountered: