Changeset 1f8e61f


Ignore:
Timestamp:
Nov 10, 2009 8:11:08 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
a6239e2c
Parents:
c40f845
Message:

verify using closest-to-the-key

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    rc40f845 r1f8e61f  
    11package net.i2p.router.networkdb.kademlia;
    22
    3 import java.util.Collections;
     3import java.util.HashSet;
    44import java.util.List;
     5import java.util.Set;
    56
    67import net.i2p.data.DataStructure;
     
    8485    }
    8586   
    86     /** todo pick one close to the key */
     87    /**
     88     *  Pick a responsive floodfill close to the key, but not the one we sent to
     89     */
    8790    private Hash pickTarget() {
     91        Set<Hash> ignore = null;
     92        if (_sentTo != null) {
     93            ignore = new HashSet(1);
     94            ignore.add(_sentTo);
     95        }
     96        Hash rkey = getContext().routingKeyGenerator().getRoutingKey(_key);
    8897        FloodfillPeerSelector sel = (FloodfillPeerSelector)_facade.getPeerSelector();
    89         List<Hash> peers = sel.selectFloodfillParticipants(_facade.getKBuckets());
    90         Collections.shuffle(peers, getContext().random());
    91         for (int i = 0; i < peers.size(); i++) {
    92             Hash rv = peers.get(i);
    93             if (!rv.equals(_sentTo))
    94                 return rv;
    95         }
     98        List<Hash> peers = sel.selectFloodfillParticipants(rkey, 1, ignore, _facade.getKBuckets());
     99        if (peers.size() > 0)
     100            return peers.get(0);
    96101       
    97102        if (_log.shouldLog(Log.WARN))
Note: See TracChangeset for help on using the changeset viewer.