net.i2p.router.networkdb.kademlia
Class KBucketSet
java.lang.Object
net.i2p.router.networkdb.kademlia.KBucketSet
class KBucketSet
- extends java.lang.Object
In memory storage of buckets sorted by the XOR metric from the local router's
identity, with bucket N containing routers BASE^N through BASE^N+1 away, up through
2^256 bits away (since we use SHA256).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
BASE
public static final int BASE
- See Also:
- Constant Field Values
KEYSIZE_BITS
public static final int KEYSIZE_BITS
- See Also:
- Constant Field Values
NUM_BUCKETS
public static final int NUM_BUCKETS
- See Also:
- Constant Field Values
BUCKET_SIZE
public static final int BUCKET_SIZE
- See Also:
- Constant Field Values
KBucketSet
public KBucketSet(I2PAppContext context,
Hash us)
add
public boolean add(Hash peer)
- Return true if the peer is new to the bucket it goes in, or false if it was
already in it
size
public int size()
- Not an exact count (due to concurrency issues) but generally correct
remove
public boolean remove(Hash entry)
getAll
public java.util.Set getAll()
getAll
public java.util.Set getAll(java.util.Set toIgnore)
getAll
public void getAll(SelectionCollector collector)
pickBucket
public int pickBucket(Hash key)
getBucket
public KBucket getBucket(int bucket)
createBuckets
protected void createBuckets()
createBucket
protected KBucket createBucket(int start,
int end)
displayBuckets
public void displayBuckets()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
toString
static final java.lang.String toString(byte[] b)
main
public static void main(java.lang.String[] args)