From b99f9d870dceaae895c019102c8c88cae79007b5 Mon Sep 17 00:00:00 2001 From: hydrox Date: Thu, 22 Mar 2007 09:08:38 +0000 Subject: [PATCH] *) fixed double selection of peers for the same DHT-chunk. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3513 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/yacy/yacyDHTAction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/de/anomic/yacy/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.java index c57801e57..7aaa7f999 100644 --- a/source/de/anomic/yacy/yacyDHTAction.java +++ b/source/de/anomic/yacy/yacyDHTAction.java @@ -45,6 +45,7 @@ package de.anomic.yacy; import java.util.ArrayList; import java.util.Enumeration; +import java.util.Hashtable; import de.anomic.kelondro.kelondroBase64Order; import de.anomic.kelondro.kelondroException; @@ -280,13 +281,15 @@ public class yacyDHTAction implements yacyPeerAction { double avdist; Enumeration e = this.getAcceptRemoteIndexSeeds(lastKey); + Hashtable peerFilter = new Hashtable(); while ((e.hasMoreElements()) && (seeds.size() < (primaryPeerCount + reservePeerCount))) { seed = (yacySeed) e.nextElement(); if (seeds != null) { avdist = Math.max(yacyDHTAction.dhtDistance(seed.hash, firstKey), yacyDHTAction.dhtDistance(seed.hash, lastKey)); - if (avdist < maxDistance) { + if (avdist < maxDistance && !peerFilter.containsKey(seed.hash)) { if (log != null) log.logInfo("Selected " + ((seeds.size() < primaryPeerCount) ? "primary" : "reserve") + " DHT target peer " + seed.getName() + ":" + seed.hash + ", distance = " + avdist); seeds.add(seed); + peerFilter.put(seed.hash, seed); } } }