Tabnine Logo
KBucketSet.getAll
Code IndexAdd Tabnine to your IDE (free)

How to use
getAll
method
in
net.i2p.kademlia.KBucketSet

Best Java code snippets using net.i2p.kademlia.KBucketSet.getAll (Showing top 4 results out of 315)

origin: i2p/i2p.i2p

/**
 *  @return a copy in a new set
 */
public Set<T> getAll(Set<T> toIgnore) {
  Set<T> all = getAll();
  all.removeAll(toIgnore);
  return all;
}

origin: i2p/i2p.i2p

/**
 * 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.
 *
 * @param key the ROUTING key (NOT the original key)
 * @param peersToIgnore can be null
 * @return List of Hash for the peers selected
 */
List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet<Hash> kbuckets, boolean preferConnected) { 
  if (peersToIgnore == null)
    peersToIgnore = Collections.singleton(_context.routerHash());
  else
    peersToIgnore.add(_context.routerHash());
  // TODO this is very slow
  FloodfillSelectionCollector matches = new FloodfillSelectionCollector(key, peersToIgnore, maxNumRouters);
  if (kbuckets == null) return new ArrayList<Hash>();
  kbuckets.getAll(matches);
  List<Hash> rv = matches.get(maxNumRouters, preferConnected);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("Searching for " + maxNumRouters + " peers close to " + key + ": " 
          + rv + " (not including " + peersToIgnore + ") [allHashes.size = " 
          + matches.size() + "]", new Exception("Search by"));
  return rv;
}

origin: i2p/i2p.i2p

/**
 * 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.
 *
 * @return List of Hash for the peers selected, ordered by bucket (but intra bucket order is not defined)
 */
List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet<Hash> kbuckets) {
  if (peersToIgnore == null)
    peersToIgnore = new HashSet<Hash>(1);
  peersToIgnore.add(_context.routerHash());
  MatchSelectionCollector matches = new MatchSelectionCollector(key, peersToIgnore);
  kbuckets.getAll(matches);
  List<Hash> rv = matches.get(maxNumRouters);
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("Searching for " + maxNumRouters + " peers close to " + key + ": " 
          + rv + " (not including " + peersToIgnore + ") [allHashes.size = " 
          + matches.size() + "]");
  return rv;
}

origin: i2p/i2p.i2p

  /**
   * 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
   *
   * @param key the original key (NOT the routing key)
   * @param peersToIgnore can be null
   * @return List of Hash for the peers selected, ordered
   */
  @Override
  List<Hash> selectNearest(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet<Hash> kbuckets) {
    Hash rkey = _context.routingKeyGenerator().getRoutingKey(key);
    if (peersToIgnore != null && peersToIgnore.contains(Hash.FAKE_HASH)) {
      // return non-ff
      peersToIgnore.addAll(selectFloodfillParticipants(peersToIgnore, kbuckets));
      // TODO this is very slow
      FloodfillSelectionCollector matches = new FloodfillSelectionCollector(rkey, peersToIgnore, maxNumRouters);
      kbuckets.getAll(matches);
      return matches.get(maxNumRouters);
    } else {
      // return ff
      return selectFloodfillParticipantsIncludingUs(rkey, maxNumRouters, peersToIgnore, kbuckets);
    }
  }
}
net.i2p.kademliaKBucketSetgetAll

Popular methods of KBucketSet

  • <init>
    Use the supplied trim strategy.
  • add
  • getClosest
    The keys closest to the key. Returned list will never contain us.
  • getExploreKeys
    For every bucket that hasn't been updated in this long, or isn't close to full, generate a random ke
  • toString
  • clear
  • generateRandomKey
    Generate a random key to go within this bucket Package private for testing only. Others shouldn't ne
  • getRange
    The number of bits minus 1 (range number) for the xor of the key. Package private for testing only.
  • remove
  • size
    The current number of entries.
  • createBucket
  • createBuckets
  • createBucket,
  • createBuckets,
  • getBucket,
  • getBuckets,
  • getReadLock,
  • getWriteLock,
  • locked_split,
  • makeKey,
  • pickBucket

Popular in Java

  • Making http requests using okhttp
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • getSystemService (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now