net.i2p.router.networkdb.kademlia

## Class PeerSelector

- java.lang.Object
- - net.i2p.router.networkdb.kademlia.PeerSelector

- Direct Known Subclasses:
    FloodfillPeerSelector

       class PeerSelector
      extends Object

  Mostly unused, see overrides in FloodfillPeerSelector

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context`
    `protected Log` | `_log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PeerSelector(RouterContext ctx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) List<Hash>` | `selectMostReliablePeers(Hash key, int numClosest, Set<Hash> alreadyChecked, KBucketSet kbuckets)` UNUSED - See FloodfillPeerSelector override Search through the kbucket set to find the most reliable peers close to the given key, skipping all of the ones already checked List will not include our own hash.
    `(package private) List<Hash>` | `selectNearest(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet kbuckets)` UNUSED - See FloodfillPeerSelector override Generic KBucket filtering to find the hashes close to a key, regardless of other considerations.
    `(package private) List<Hash>` | `selectNearestExplicit(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet kbuckets)` Ignore KBucket ordering and do the XOR explicitly per key.
    `(package private) List<Hash>` | `selectNearestExplicitThin(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet kbuckets)` UNUSED - See FloodfillPeerSelector override Ignore KBucket ordering and do the XOR explicitly per key.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _log

          protected final Log _log

    - #### _context

          protected final RouterContext _context

  - ### Constructor Detail

    - #### PeerSelector

          public PeerSelector(RouterContext ctx)

  - ### Method Detail

    - #### selectMostReliablePeers

          List<Hash> selectMostReliablePeers(Hash key,
                                           int numClosest,
                                           Set<Hash> alreadyChecked,
                                           KBucketSet kbuckets)

      UNUSED - See FloodfillPeerSelector override Search through the kbucket set to find the most reliable peers close to the given key, skipping all of the ones already checked List will not include our own hash.
      Returns:
        ordered list of Hash objects

    - #### selectNearestExplicit

          List<Hash> selectNearestExplicit(Hash key,
                                         int maxNumRouters,
                                         Set<Hash> peersToIgnore,
                                         KBucketSet kbuckets)

      Ignore KBucket ordering and do the XOR explicitly per key. Runs in O(n*log(n)) time (n=routing table size with c ~ 32 xor ops). This gets strict ordering on closest List will not include our own hash.
      Returns:
        List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)

    - #### selectNearestExplicitThin

          List<Hash> selectNearestExplicitThin(Hash key,
                                             int maxNumRouters,
                                             Set<Hash> peersToIgnore,
                                             KBucketSet kbuckets)

      UNUSED - See FloodfillPeerSelector override Ignore KBucket ordering and do the XOR explicitly per key. Runs in O(n*log(n)) time (n=routing table size with c ~ 32 xor ops). This gets strict ordering on closest List will not include our own hash.
      Returns:
        List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)

    - #### selectNearest

          List<Hash> selectNearest(Hash key,
                                 int maxNumRouters,
                                 Set<Hash> peersToIgnore,
                                 KBucketSet kbuckets)

      UNUSED - See FloodfillPeerSelector override Generic KBucket filtering to find the hashes close to a key, regardless of other considerations. This goes through the kbuckets, starting with the key's location, moving towards us, and then away from the key's location's bucket, selecting peers until we have numClosest. List MAY INCLUDE our own router - add to peersToIgnore if you don't want
      Parameters:
        `key` - the original key (NOT the routing key)
        `peersToIgnore` - can be null
      Returns:
        List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)