git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3438 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2007-03-07 09:26:01 +00:00
parent 958ebea5c5
commit 313f6a7680

View File

@ -168,15 +168,25 @@ public class plasmaDHTChunk {
String startPointHash;
// first try to select with increasing probality a good start point
double minimumDistance = ((double) peerRedundancy) / ((double) yacyCore.seedDB.sizeConnected());
if (Math.round(Math.random() * 6) != 4)
for (int i = 9; i > 0; i--) {
startPointHash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(i + System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
if (yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, startPointHash) > (minimumDistance + ((double) i / (double) 10)))
return startPointHash;
double d, bestDistance = 0.0;
String bestHash = null;
for (int i = yacyCore.seedDB.sizeConnected() / 8; i > 0; i--) {
startPointHash = kelondroBase64Order.enhancedCoder.encode(serverCodings.encodeMD5Raw(Long.toString(i + System.currentTimeMillis()))).substring(2, 2 + yacySeedDB.commonHashLength);
d = yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, startPointHash);
if (d > (minimumDistance + ((double) i / (double) 10))) {
return startPointHash;
}
// if that fails, take simply the best start point (this is usually avoided, since that leads to always the same target peers)
startPointHash = yacyCore.seedDB.mySeed.hash.substring(0, 11) + "z";
return startPointHash;
if (d > bestDistance) {
bestDistance = d;
bestHash = startPointHash;
}
}
// if that fails, take simply the best start point
if (bestHash == null) {
return yacyCore.seedDB.mySeed.hash.substring(0, 11) + "z";
} else {
return bestHash;
}
}
private void selectTransferContainers(String hash, int mincount, int maxcount, int maxtime) throws InterruptedException {