PeerMap implements PeerStatusListener, Maintainable { public static int isKadCloser(final Number160 id, final PeerAddress rn, final PeerAddress rn2) { return distance(id, rn.peerId()).compareTo(distance(id, rn2.peerId())); } 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 testCloser() throws UnknownHostException { PeerAddress rn1 = new PeerAddress(new Number160("0x7f")); PeerAddress rn2 = new PeerAddress(new Number160("0x40")); Number160 key = new Number160("0xff"); Assert.assertEquals(-1, PeerMap.isKadCloser(key, rn1, rn2)); rn1 = new PeerAddress(new Number160("0x10")); rn2 = new PeerAddress(new Number160("0x11")); key = new Number160("0xff"); System.err.println("0x7f xor 0xff " + rn1.peerId().xor(key)); System.err.println("0x40 xor 0xff " + rn2.peerId().xor(key)); Assert.assertEquals(1, PeerMap.isKadCloser(key, rn1, rn2)); }