net.i2p.router.networkdb.kademlia
Interface KBucket

All Known Implementing Classes:
KBucketImpl

interface KBucket

Group, without inherent ordering, a set of keys a certain distance away from a local key, using XOR as the distance metric


Method Summary
 int add(Hash key)
          Add the peer to the bucket
 Hash generateRandomKey()
          Generate a random key that would go inside this bucket
 java.util.Set<Hash> getEntries()
          Retrieve all routing table entries stored in the bucket
 void getEntries(SelectionCollector collector)
           
 java.util.Set<Hash> getEntries(java.util.Set<Hash> toIgnoreHashes)
          Retrieve hashes stored in the bucket, excluding the ones specified
 int getKeyCount()
          Number of keys already contained in this kbuckey
 LocalHash getLocal()
           
 int getRangeBegin()
          lowest order high bit for difference keys
 int getRangeEnd()
          highest high bit for the difference keys
 boolean remove(Hash key)
          Remove the key from the bucket
 void setEntries(java.util.Set<Hash> entries)
          Fill the bucket with entries
 void setRange(int lowOrderBitLimit, int highOrderBitLimit)
          Set the range low and high bits for difference keys
 boolean shouldContain(Hash key)
          whether or not the key qualifies as part of this bucket
 

Method Detail

getRangeBegin

int getRangeBegin()
lowest order high bit for difference keys


getRangeEnd

int getRangeEnd()
highest high bit for the difference keys


setRange

void setRange(int lowOrderBitLimit,
              int highOrderBitLimit)
Set the range low and high bits for difference keys


getKeyCount

int getKeyCount()
Number of keys already contained in this kbuckey


shouldContain

boolean shouldContain(Hash key)
whether or not the key qualifies as part of this bucket


add

int add(Hash key)
Add the peer to the bucket

Returns:
number of keys in the bucket after the addition

remove

boolean remove(Hash key)
Remove the key from the bucket

Returns:
true if the key existed in the bucket before removing it, else false

getEntries

java.util.Set<Hash> getEntries()
Retrieve all routing table entries stored in the bucket

Returns:
set of Hash structures

getEntries

java.util.Set<Hash> getEntries(java.util.Set<Hash> toIgnoreHashes)
Retrieve hashes stored in the bucket, excluding the ones specified

Returns:
set of Hash structures

getEntries

void getEntries(SelectionCollector collector)

setEntries

void setEntries(java.util.Set<Hash> entries)
Fill the bucket with entries

Parameters:
entries - set of Hash structures

generateRandomKey

Hash generateRandomKey()
Generate a random key that would go inside this bucket


getLocal

LocalHash getLocal()