PeerMap implements PeerStatusListener, Maintainable { public NavigableSet<PeerStatistic> closePeers(final int atLeast) { return closePeers(self, atLeast); } PeerMap(final PeerMapConfiguration peerMapConfiguration); void addPeerMapChangeListener(final PeerMapChangeListener peerMapChangeListener); void removePeerMapChangeListener(final PeerMapChangeListener peerMapChangeListener); int size(); Number160 self(); @Override boolean peerFound(final PeerAddress remotePeer, final PeerAddress referrer, final PeerConnection peerConnection, RTT roundTripTime); @Override boolean peerFailed(final PeerAddress remotePeer, final PeerException peerException); boolean contains(final PeerAddress peerAddress); boolean containsOverflow(final PeerAddress peerAddress); PeerStatistic getPeerStatistic(final PeerAddress peerAddress); NavigableSet<PeerStatistic> closePeers(final int atLeast); NavigableSet<PeerStatistic> closePeers(final Number160 id, final int atLeast); static NavigableSet<PeerStatistic> closePeers(final Number160 self, final Number160 other,
                                                         final int atLeast,
                                                         List<Map<Number160, PeerStatistic>> peerMap,
                                                         Comparator<PeerStatistic> comparator); @Override String toString(); Comparator<PeerAddress> createXORAddressComparator(); List<PeerAddress> all(); List<PeerAddress> fromEachBag(final int nrNeighbors, final int maxBucket); List<Map<Number160, PeerStatistic>> peerMapVerified(); List<Map<Number160, PeerStatistic>> peerMapOverflow(); List<PeerAddress> allOverflow(); boolean isPeerRemovedTemporarly(final PeerAddress peerAddress); PeerStatistic nextForMaintenance(Collection<PeerAddress> notInterestedAddresses); static int isKadCloser(final Number160 id, final PeerAddress rn, final PeerAddress rn2); static int isKadCloser(final Number160 id, final Number160 rn, final Number160 rn2); static int classCloser(final Number160 ln, final PeerAddress rn, final PeerAddress rn2); static Comparator<Number160> createXORNumberComparator(final Number160 location); static Comparator<PeerAddress> createXORAddressComparator(final Number160 location); static Comparator<PeerStatistic> createXORStatisticComparator(final Number160 location); Comparator<PeerStatistic> createStatisticComparator(final Number160 location); Collection<PeerStatistic> getPeerStatistics(Collection<PeerAddress> peerAddresses); static int classMember(final Number160 id1, final Number160 id2); static PeerStatistic updateExistingVerifiedPeerAddress(
            final Map<Number160, PeerStatistic> tmp, final PeerAddress peerAddress, final boolean firstHand, RTT roundTripTime); int bagSizeVerified(int bag); int bagSizeOverflow(int bag); int nrFilledBags();  }
@Test public void testCloser2() throws UnknownHostException { PeerAddress rn1 = new PeerAddress(new Number160(98)); PeerAddress rn2 = new PeerAddress(new Number160(66)); PeerAddress rn3 = new PeerAddress(new Number160(67)); PeerMapConfiguration conf = new PeerMapConfiguration(ID); conf.setFixedVerifiedBagSizes(3).setFixedOverflowBagSizes(3); conf.offlineCount(1000).offlineTimeout(60); conf.addMapPeerFilter(new DefaultPeerFilter()).maintenance(new DefaultMaintenance(0, new int[] {})); PeerMap peerMap = new PeerMap(conf); SortedSet<PeerStatistic> rc = peerMap.closePeers(new Number160(98), 3); rc.add(new PeerStatistic(rn2)); rc.add(new PeerStatistic(rn1)); rc.add(new PeerStatistic(rn3)); Assert.assertTrue(rc.first().peerAddress().equals(rn1)); }