|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.kademlia.KBucketSet<T>
public class KBucketSet<T extends SimpleDataStructure>
In-memory storage of buckets sorted by the XOR metric from the base (us) passed in via the constructor. This starts with one bucket covering the whole key space, and may eventually be split to a max of the number of bits in the data type (160 for SHA1Hash or 256 for Hash), times 2**(B-1) for Kademlia value B. Refactored from net.i2p.router.networkdb.kademlia
Constructor Summary | |
---|---|
KBucketSet(I2PAppContext context,
T us,
int max,
int b)
Use the default trim strategy, which removes a random entry. |
|
KBucketSet(I2PAppContext context,
T us,
int max,
int b,
KBucketTrimmer trimmer)
Use the supplied trim strategy. |
Method Summary | |
---|---|
boolean |
add(T peer)
|
void |
clear()
|
(package private) T |
generateRandomKey(KBucket bucket)
Generate a random key to go within this bucket Package private for testing only. |
Set<T> |
getAll()
|
void |
getAll(SelectionCollector<T> collector)
|
Set<T> |
getAll(Set<T> toIgnore)
|
(package private) List<KBucket<T>> |
getBuckets()
Returned list is a copy of the bucket list, closest first, with the actual buckets (not a copy). |
List<T> |
getClosest(int max)
The keys closest to us. |
List<T> |
getClosest(int max,
Collection<T> toIgnore)
The keys closest to us. |
List<T> |
getClosest(T key,
int max)
The keys closest to the key. |
List<T> |
getClosest(T key,
int max,
Collection<T> toIgnore)
The keys closest to the key. |
List<T> |
getExploreKeys(long age)
For every bucket that hasn't been updated in this long, or isn't close to full, generate a random key that would be a member of that bucket. |
(package private) int |
getRange(T key)
The number of bits minus 1 (range number) for the xor of the key. |
boolean |
remove(T entry)
|
int |
size()
The current number of entries. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public KBucketSet(I2PAppContext context, T us, int max, int b)
us
- the local identity (typically a SHA1Hash or Hash)
The class must have a zero-argument constructor.max
- the Kademlia value "k", the max per bucket, k >= 4b
- the Kademlia value "b", split buckets an extra 2**(b-1) times,
b > 0, use 1 for bittorrent, Kademlia paper recommends 5public KBucketSet(I2PAppContext context, T us, int max, int b, KBucketTrimmer trimmer)
Method Detail |
---|
public boolean add(T peer)
public int size()
public boolean remove(T entry)
public void clear()
public Set<T> getAll()
public Set<T> getAll(Set<T> toIgnore)
public void getAll(SelectionCollector<T> collector)
public List<T> getClosest(int max)
public List<T> getClosest(int max, Collection<T> toIgnore)
public List<T> getClosest(T key, int max)
public List<T> getClosest(T key, int max, Collection<T> toIgnore)
List<KBucket<T>> getBuckets()
int getRange(T key)
public List<T> getExploreKeys(long age)
T generateRandomKey(KBucket bucket)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |