verify using closest-to-the-key
This commit is contained in:
@ -1,7 +1,8 @@
|
|||||||
package net.i2p.router.networkdb.kademlia;
|
package net.i2p.router.networkdb.kademlia;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import net.i2p.data.DataStructure;
|
import net.i2p.data.DataStructure;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
@ -83,16 +84,20 @@ public class FloodfillVerifyStoreJob extends JobImpl {
|
|||||||
getContext().tunnelDispatcher().dispatchOutbound(lookup, outTunnel.getSendTunnelId(0), _target);
|
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() {
|
private Hash pickTarget() {
|
||||||
FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector();
|
Set<Hash> ignore = null;
|
||||||
List<Hash> peers = sel.selectFloodfillParticipants(_facade.getKBuckets());
|
if (_sentTo != null) {
|
||||||
Collections.shuffle(peers, getContext().random());
|
ignore = new HashSet(1);
|
||||||
for (int i = 0; i < peers.size(); i++) {
|
ignore.add(_sentTo);
|
||||||
Hash rv = peers.get(i);
|
|
||||||
if (!rv.equals(_sentTo))
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
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))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("No other peers to verify floodfill with, using the one we sent to");
|
_log.warn("No other peers to verify floodfill with, using the one we sent to");
|
||||||
|
Reference in New Issue
Block a user