public class HashDistance extends Object
Computes the XOR distance between two router hashes by performing a bitwise XOR operation on the hash data. Used in Kademlia-based distributed hash tables for determining key proximity and routing decisions.
Returns the result as a BigInteger to handle the full 256-bit hash space without overflow issues. The distance metric is fundamental to Kademlia DHT operations including key lookup, peer selection, and network topology analysis.
| Modifier and Type | Method and Description |
|---|---|
static int | compare(Hash a,
Hash b,
Hash c,
Hash d)Compare two XOR distances without allocating BigInteger. |
static BigInteger | getDistance(Hash targetKey,
Hash routerInQuestion)Compute XOR distance between two hashes. |
public static int compare(Hash a, Hash b, Hash c, Hash d)
public static BigInteger getDistance(Hash targetKey, Hash routerInQuestion)
compare(Hash, Hash, Hash, Hash).