I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 1f8e61f4 authored by zzz's avatar zzz
Browse files

verify using closest-to-the-key

parent c40f8452
No related branches found
No related tags found
No related merge requests found
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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment