/** * Updates <code>notQueriedYet</code> with the <code>k</code> closest locally known peers.<br/> * This has the the same effect as sending a <code>FindClosePeersPacket</code> to the local destination, * but without the network round-trip. * @param key * @see IncomingPacketHandler#packetReceived(CommunicationPacket, Destination, long) */ private void addLocalResults(Hash key) { log.debug("Adding local results for key " + key.toBase64()); responses.add(localDestination); Collection<Destination> closestPeers = bucketManager.getClosestPeers(key, KademliaConstants.K); addPeersToBeQueried(closestPeers); }
private void sendPeerList(FindClosePeersPacket packet, Destination destination) { Collection<Destination> closestPeers = bucketManager.getClosestPeers(packet.getKey(), KademliaConstants.K); PeerList peerList = new PeerList(closestPeers); sendQueue.sendResponse(peerList, destination, packet.getPacketId()); }
if (!keysToSkip.contains(dhtKey)) { StoreRequest request = new StoreRequest(packet); List<Destination> closestPeers = bucketManager.getClosestPeers(dhtKey, KademliaConstants.K); for (Destination peer: closestPeers) {