diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java index 3706606e408c55c61beb0c88373790b2f552de79..6627b0905ceca9a904d5590c9ce99f76d8d75664 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java @@ -1,7 +1,8 @@ package net.i2p.router.networkdb.kademlia; -import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import net.i2p.data.DataStructure; import net.i2p.data.Hash; @@ -83,16 +84,20 @@ public class FloodfillVerifyStoreJob extends JobImpl { getContext().tunnelDispatcher().dispatchOutbound(lookup, outTunnel.getSendTunnelId(0), _target); } - /** todo pick one close to the key */ + /** + * Pick a responsive floodfill close to the key, but not the one we sent to + */ private Hash pickTarget() { - FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector(); - List<Hash> peers = sel.selectFloodfillParticipants(_facade.getKBuckets()); - Collections.shuffle(peers, getContext().random()); - for (int i = 0; i < peers.size(); i++) { - Hash rv = peers.get(i); - if (!rv.equals(_sentTo)) - return rv; + Set<Hash> ignore = null; + if (_sentTo != null) { + ignore = new HashSet(1); + ignore.add(_sentTo); } + Hash rkey = getContext().routingKeyGenerator().getRoutingKey(_key); + FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector(); + List<Hash> peers = sel.selectFloodfillParticipants(rkey, 1, ignore, _facade.getKBuckets()); + if (peers.size() > 0) + return peers.get(0); if (_log.shouldLog(Log.WARN)) _log.warn("No other peers to verify floodfill with, using the one we sent to");