|
|
|
@ -45,8 +45,8 @@ package de.anomic.yacy;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Enumeration;
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
|
|
|
|
|
import de.anomic.kelondro.kelondroBase64Order;
|
|
|
|
|
import de.anomic.kelondro.kelondroCloneableIterator;
|
|
|
|
@ -303,9 +303,9 @@ public class yacyDHTAction implements yacyPeerAction {
|
|
|
|
|
double ownDistance = Math.min(yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, firstKey), yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, lastKey));
|
|
|
|
|
double maxDistance = Math.min(ownDistance, maxDist);
|
|
|
|
|
|
|
|
|
|
double avdist, firstdist, lastdist;
|
|
|
|
|
double firstdist, lastdist;
|
|
|
|
|
Enumeration e = this.getAcceptRemoteIndexSeeds(lastKey);
|
|
|
|
|
Hashtable peerFilter = new Hashtable();
|
|
|
|
|
TreeSet doublecheck = new TreeSet(kelondroBase64Order.enhancedCoder);
|
|
|
|
|
int maxloop = Math.min(100, yacyCore.seedDB.sizeConnected()); // to ensure termination
|
|
|
|
|
if (log != null) log.logInfo("Collecting DHT target peers for first_hash = " + firstKey + ", last_hash = " + lastKey);
|
|
|
|
|
while ((e.hasMoreElements()) && (seeds.size() < (primaryPeerCount + reservePeerCount)) && (maxloop-- > 0)) {
|
|
|
|
@ -313,11 +313,10 @@ public class yacyDHTAction implements yacyPeerAction {
|
|
|
|
|
if (seeds != null) {
|
|
|
|
|
firstdist = yacyDHTAction.dhtDistance(seed.hash, firstKey);
|
|
|
|
|
lastdist = yacyDHTAction.dhtDistance(seed.hash, lastKey);
|
|
|
|
|
avdist = Math.max(firstdist, lastdist);
|
|
|
|
|
if (avdist < maxDistance && !peerFilter.containsKey(seed.hash)) {
|
|
|
|
|
if ((lastdist < maxDistance) && (!(doublecheck.contains(seed.hash)))) {
|
|
|
|
|
if (log != null) log.logInfo("Selected " + ((seeds.size() < primaryPeerCount) ? "primary" : "reserve") + " DHT target peer " + seed.getName() + ":" + seed.hash + ", distance2first = " + firstdist + ", distance2last = " + lastdist);
|
|
|
|
|
seeds.add(seed);
|
|
|
|
|
peerFilter.put(seed.hash, seed);
|
|
|
|
|
doublecheck.add(seed.hash);
|
|
|
|
|
} else {
|
|
|
|
|
if (log != null) log.logInfo("Discarded improper DHT target peer " + seed.getName() + ":" + seed.hash + ", distance2first = " + firstdist + ", distance2last = " + lastdist);
|
|
|
|
|
}
|
|
|
|
|