I'm reading through the Kademlia white paper and trying to implement the routing table piece.
I'm using a 160bit address space and have an array of 160 k-buckets. From what I understand this implementation would store node ids in the buckets by how many leading zeros bits the node id has. I.e. bucket[0]
would have node ids with 160 leading zeros (only 1 node) and bucket[159]
would have nodes with no leading zeros (50% of the entire address space).
Question Using this implementation, when finding the closest k-nodes to a target nodeId would I just count the leading zeros for the target and return everything in that k-bucket?
Using this implementation I see no place/need to use the XOR that Kademlia is built off of so I don't think my implementation is correct.