java.lang.Object
net.i2p.kademlia.KBucketSet.Range<T>
Type Parameters:
T - the key type of the buckets
Enclosing class:
KBucketSet<T extends SimpleDataStructure>

private static class KBucketSet.Range<T extends SimpleDataStructure>extends Object
Calculator of the bucket range for a key.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final BigInteger
    Our key as a big integer.
    private final int
    B value from the kademlia paper.
    private final Map<T,Integer>
    Cached range numbers, by key.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(T us, int bValue)
    Builds the range calculator.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    Clears the cached range numbers.
    int
    getRange(T key)
    XOR distance range number for the given key — the B-aligned bucket range containing the key's distance from us.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _bValue

      private final int _bValue
      B value from the kademlia paper.
    • _bigUs

      private final BigInteger _bigUs
      Our key as a big integer.
    • _distanceCache

      private final Map<T extends SimpleDataStructure, Integer> _distanceCache
      Cached range numbers, by key.
  • Constructor Details

    • Range

      public Range(T us, int bValue)
      Builds the range calculator.
      Parameters:
      us - the local node's key
      bValue - the B value from the kademlia paper
  • Method Details

    • getRange

      public int getRange(T key)
      XOR distance range number for the given key — the B-aligned bucket range containing the key's distance from us.
      Parameters:
      key - the key to measure
      Returns:
      the range number, or -1 for us
    • clear

      public void clear()
      Clears the cached range numbers.