net.i2p.router.networkdb.kademlia
Class FloodfillPeerSelector
java.lang.Object
net.i2p.router.networkdb.kademlia.PeerSelector
net.i2p.router.networkdb.kademlia.FloodfillPeerSelector
class FloodfillPeerSelector
- extends PeerSelector
This is where we implement semi-Kademlia with the floodfills, by
selecting floodfills closest to a given key for
searches and stores.
Warning - most methods taking a key as an argument require the
routing key, not the original key.
Method Summary |
java.util.List<Hash> |
selectFloodfillParticipants(Hash key,
int maxNumRouters,
KBucketSet kbuckets)
Sort the floodfills. |
java.util.List<Hash> |
selectFloodfillParticipants(Hash key,
int howMany,
java.util.Set<Hash> toIgnore,
KBucketSet kbuckets)
|
java.util.List<Hash> |
selectFloodfillParticipants(KBucketSet kbuckets)
|
java.util.List<Hash> |
selectFloodfillParticipants(java.util.Set<Hash> toIgnore,
KBucketSet kbuckets)
|
java.util.List<Hash> |
selectMostReliablePeers(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Pick out peers with the floodfill capacity set, returning them first, but then
after they're complete, sort via kademlia. |
java.util.List<Hash> |
selectNearest(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Floodfill peers only. |
java.util.List<Hash> |
selectNearestExplicitThin(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Pick out peers with the floodfill capacity set, returning them first, but then
after they're complete, sort via kademlia. |
java.util.List<Hash> |
selectNearestExplicitThin(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets,
boolean preferConnected)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FloodfillPeerSelector
public FloodfillPeerSelector(RouterContext ctx)
selectMostReliablePeers
public java.util.List<Hash> selectMostReliablePeers(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
- Pick out peers with the floodfill capacity set, returning them first, but then
after they're complete, sort via kademlia.
Puts the floodfill peers that are directly connected first in the list.
- Overrides:
selectMostReliablePeers
in class PeerSelector
- Returns:
- List of Hash for the peers selected
selectNearestExplicitThin
public java.util.List<Hash> selectNearestExplicitThin(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
- Pick out peers with the floodfill capacity set, returning them first, but then
after they're complete, sort via kademlia.
Does not prefer the floodfill peers that are directly connected.
- Overrides:
selectNearestExplicitThin
in class PeerSelector
- Returns:
- List of Hash for the peers selected
selectNearestExplicitThin
public java.util.List<Hash> selectNearestExplicitThin(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets,
boolean preferConnected)
selectFloodfillParticipants
public java.util.List<Hash> selectFloodfillParticipants(KBucketSet kbuckets)
- Returns:
- all floodfills not shitlisted forever. list will not include our own hash
List is not sorted and not shuffled.
selectFloodfillParticipants
public java.util.List<Hash> selectFloodfillParticipants(java.util.Set<Hash> toIgnore,
KBucketSet kbuckets)
selectFloodfillParticipants
public java.util.List<Hash> selectFloodfillParticipants(Hash key,
int maxNumRouters,
KBucketSet kbuckets)
- Sort the floodfills. The challenge here is to keep the good ones
at the front and the bad ones at the back. If they are all good or bad,
searches and stores won't work well.
- Parameters:
key
- the routing keymaxNumRouters
- max to return
Sorted by closest to the key if > maxNumRouters, otherwise not
The list is in 3 groups - sorted by routing key within each group.
Group 1: No store or lookup failure in a long time, and
lookup fail rate no more than 1.5 * average
Group 2: No store or lookup failure in a little while or
success newer than failure
Group 3: All others
- Returns:
- all floodfills not shitlisted foreverx
selectFloodfillParticipants
public java.util.List<Hash> selectFloodfillParticipants(Hash key,
int howMany,
java.util.Set<Hash> toIgnore,
KBucketSet kbuckets)
selectNearest
public java.util.List<Hash> selectNearest(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
- Floodfill peers only. Used only by HandleDatabaseLookupMessageJob to populate the DSRM.
UNLESS peersToIgnore contains Hash.FAKE_HASH (all zeros), in which case this is an exploratory
lookup, and the response should not include floodfills.
- Overrides:
selectNearest
in class PeerSelector
- Parameters:
key
- the original key (NOT the routing key)
- Returns:
- List of Hash for the peers selected, ordered