I am currently trying to understand the node discovery protocol in ethereum. I found a few docs, where one of it is: https://github.com/ethereum/devp2p/blob/master/discv4.md
It says, that the distance between node is determined the following way
distance(n₁, n₂) = keccak256(n₁) XOR keccak256(n₂)
where n
is the node ID.
Next, the information about neighbors is stored in a routing table consisting of 'k-buckets'.
What I don't understand is the following sentence:
For each 0 ≤ i < 256, every node keeps a k-bucket for nodes of distance between 2^i and 2^(i+1) from itself.
Let's say we have n1 = 0x80
and n2 = 0xF0
. To keep it simple, we don't hash but use just the id. So we get the following distance: d = 0x70
. The MSB differs now. In which bucket do I store the information now?