fix for DHT selection target

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3722 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 4e68a10cd9
commit e897eb9b4a

@ -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);
}

Loading…
Cancel
Save