Class 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.
    • Constructor Detail

      • FloodfillPeerSelector

        public FloodfillPeerSelector​(RouterContext ctx)
    • Method Detail

      • selectMostReliablePeers

        List<Hash> selectMostReliablePeers​(Hash key,
                                           int maxNumRouters,
                                           Set<Hash> peersToIgnore,
                                           KBucketSet<Hash> 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. List will not include our own hash. Returns new list, may be modified.
        Overrides:
        selectMostReliablePeers in class PeerSelector
        Parameters:
        key - the ROUTING key (NOT the original key)
        peersToIgnore - can be null
        Returns:
        List of Hash for the peers selected
      • selectNearestExplicitThin

        List<Hash> selectNearestExplicitThin​(Hash key,
                                             int maxNumRouters,
                                             Set<Hash> peersToIgnore,
                                             KBucketSet<Hash> 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. List will not include our own hash. Returns new list, may be modified.
        Overrides:
        selectNearestExplicitThin in class PeerSelector
        Parameters:
        key - the ROUTING key (NOT the original key)
        peersToIgnore - can be null
        Returns:
        List of Hash for the peers selected
      • selectNearestExplicitThin

        List<Hash> selectNearestExplicitThin​(Hash key,
                                             int maxNumRouters,
                                             Set<Hash> peersToIgnore,
                                             KBucketSet<Hash> kbuckets,
                                             boolean preferConnected)
        Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia. List will not include our own hash. Returns new list, may be modified.
        Parameters:
        key - the ROUTING key (NOT the original key)
        peersToIgnore - can be null
        Returns:
        List of Hash for the peers selected
      • selectFloodfillParticipants

        List<Hash> selectFloodfillParticipants​(KBucketSet<Hash> kbuckets)
        List will not include our own hash. List is not sorted and not shuffled. Returns new list, may be modified.
        Parameters:
        kbuckets - now unused
        Returns:
        all floodfills not banlisted forever.
      • selectFloodfillParticipants

        List<Hash> selectFloodfillParticipants​(Hash key,
                                               int maxNumRouters,
                                               KBucketSet<Hash> 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. List will not include our own hash. Returns new list, may be modified.
        Parameters:
        key - the ROUTING key (NOT the original key)
        maxNumRouters - max to return
        kbuckets - now unused 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:
        floodfills closest to the key that are not banlisted forever
      • selectFloodfillParticipants

        List<Hash> selectFloodfillParticipants​(Hash key,
                                               int howMany,
                                               Set<Hash> toIgnore,
                                               KBucketSet<Hash> kbuckets)
        See above for description List will not include our own hash Returns new list, may be modified.
        Parameters:
        key - the ROUTING key (NOT the original key)
        toIgnore - can be null
        kbuckets - now unused
      • selectNearest

        List<Hash> selectNearest​(Hash key,
                                 int maxNumRouters,
                                 Set<Hash> peersToIgnore,
                                 KBucketSet<Hash> 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. List MAY INCLUDE our own router - add to peersToIgnore if you don't want
        Overrides:
        selectNearest in class PeerSelector
        Parameters:
        key - the original key (NOT the routing key)
        peersToIgnore - can be null
        Returns:
        List of Hash for the peers selected, ordered