/** * Warning - may return our router hash - add to toIgnore if necessary * @param key the ROUTING key (NOT the original key) * @param toIgnore can be null */ public FloodfillSelectionCollector(Hash key, Set<Hash> toIgnore, int wanted) { _key = key; _sorted = new TreeSet<Hash>(new XORComparator<Hash>(key)); _floodfillMatches = new ArrayList<Hash>(8); _toIgnore = toIgnore; _wanted = wanted; }
private Set<Hash> locked_getClosest(Set<Hash> peers, int max, Hash target) { if (_attemptedPeers.size() <= max) return new HashSet<Hash>(_attemptedPeers); TreeSet<Hash> closest = new TreeSet<Hash>(new XORComparator<Hash>(target)); closest.addAll(_attemptedPeers); Set<Hash> rv = new HashSet<Hash>(max); int i = 0; for (Iterator<Hash> iter = closest.iterator(); iter.hasNext() && i < max; i++) { rv.add(iter.next()); } return rv; }
Comparator<T> comp = new XORComparator<T>(_us); Collections.sort(rv, comp); int sz = rv.size();
Comparator<T> comp = new XORComparator<T>(key); Collections.sort(rv, comp); int sz = rv.size();
/** * Lookup using the client's tunnels. * Do not use for RI lookups down client tunnels, * as the response will be dropped in InboundMessageDistributor. * @param fromLocalDest use these tunnels for the lookup, or null for exploratory * @since 0.9.10 */ public IterativeSearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease, Hash fromLocalDest) { super(ctx, facade, key, onFind, onFailed, timeoutMs, isLease); // these override the settings in super _timeoutMs = Math.min(timeoutMs, MAX_SEARCH_TIME); _expiration = _timeoutMs + ctx.clock().now(); _rkey = ctx.routingKeyGenerator().getRoutingKey(key); _toTry = new TreeSet<Hash>(new XORComparator<Hash>(_rkey)); int totalSearchLimit = (facade.floodfillEnabled() && ctx.router().getUptime() > 30*60*1000) ? TOTAL_SEARCH_LIMIT_WHEN_FF : TOTAL_SEARCH_LIMIT; _totalSearchLimit = ctx.getProperty("netdb.searchLimit", totalSearchLimit); _ipSet = new MaskedIPSet(2 * (_totalSearchLimit + EXTRA_PEERS)); _singleSearchTime = ctx.getProperty("netdb.singleSearchTime", SINGLE_SEARCH_TIME); _maxConcurrent = ctx.getProperty("netdb.maxConcurrent", MAX_CONCURRENT); _unheardFrom = new HashSet<Hash>(CONCURRENT_SEARCHES); _failedPeers = new HashSet<Hash>(_totalSearchLimit); _skippedPeers = new HashSet<Hash>(4); _sentTime = new ConcurrentHashMap<Hash, Long>(_totalSearchLimit); _fromLocalDest = fromLocalDest; if (fromLocalDest != null && !isLease && _log.shouldLog(Log.WARN)) _log.warn("Search for RI " + key + " down client tunnel " + fromLocalDest, new Exception()); // all createRateStat in FNDF }
TreeSet<Hash> sorted = new TreeSet<Hash>(new XORComparator<Hash>(key)); sorted.addAll(ffs);