net.i2p.router.networkdb.kademlia
Class KBucketSet
java.lang.Object
net.i2p.router.networkdb.kademlia.KBucketSet
class KBucketSet
- extends 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).
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)
clear
public void clear()
- Since:
- 0.8.8
getAll
public Set<Hash> getAll()
getAll
public Set<Hash> getAll(Set<Hash> toIgnore)
getAll
public void getAll(SelectionCollector collector)
pickBucket
public int pickBucket(Hash key)
getBucket
public KBucket getBucket(int bucket)
createBuckets
protected KBucket[] createBuckets()
createBucket
protected KBucket createBucket(int start,
int end)
displayBuckets
public void displayBuckets()
toString
public String toString()
- Overrides:
toString
in class Object
toString
static final String toString(byte[] b)
main
public static void main(String[] args)