java.lang.Object
net.i2p.router.networkdb.kademlia.PeerSelector
Direct Known Subclasses:
FloodfillPeerSelector

abstract class PeerSelectorextends Object
Abstract base class for peer selection in Kademlia routing tables.

All peer selection logic is implemented in FloodfillPeerSelector. This class only provides common constructor and logging functionality.

  • Field Details

    • _log

      protected final Log _log
      _log. /.
    • _context

      protected final RouterContext _context
      _context. /.
  • Constructor Details

    • PeerSelector

      public PeerSelector(RouterContext ctx)
      PeerSelector. /.
      Parameters:
      ctx - the router context whose log and profile organizer this selector uses
  • Method Details

    • selectNearest

      abstract List<Hash> selectNearest(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet<Hash> kbuckets)
      Peers nearest to the key in routing space.
      Parameters:
      key - the routing key to search for
      maxNumRouters - the most hashes to return, zero or less meaning no limit
      peersToIgnore - hashes already chosen or excluded from this selection
      kbuckets - the routing table to select from
      Returns:
      the nearest peers in ascending Kademlia distance
    • selectNearestExplicit

      abstract List<Hash> selectNearestExplicit(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet<Hash> kbuckets)
      Peers nearest to the key, floodfills first, then sorted by Kademlia distance.
      Parameters:
      key - the routing key to search for
      maxNumRouters - the most hashes to return, zero or less meaning no limit
      peersToIgnore - hashes already chosen or excluded from this selection
      kbuckets - the routing table to select from
      Returns:
      the floodfill peers nearest the key, then the other peers by distance