added a root node flag: identifies peers with short ping time

pull/1/head
Michael Peter Christen 13 years ago
parent c846e9ca14
commit 3c2bec681f

@ -171,6 +171,7 @@ public final class Protocol
Map<String, String> result = null;
final String salt = crypt.randomSalt();
long responseTime = Long.MAX_VALUE;
try {
// generate request
final Map<String, ContentBody> parts =
@ -188,6 +189,7 @@ public final class Protocol
Seed.b64Hash2hexHash(otherHash) + ".yacyh",
parts,
false);
responseTime = System.currentTimeMillis() - start;
Network.log.logInfo("yacyClient.hello thread '"
+ Thread.currentThread().getName()
+ "' contacted peer at "
@ -195,7 +197,7 @@ public final class Protocol
+ ", received "
+ ((content == null) ? "null" : content.length)
+ " bytes, time = "
+ (System.currentTimeMillis() - start)
+ responseTime
+ " milliseconds");
result = FileUtils.table(content);
} catch ( final Exception e ) {
@ -256,6 +258,12 @@ public final class Protocol
}
}
// get access type response
String mytype = result.get(Seed.YOURTYPE);
if ( mytype == null ) {
mytype = "";
}
// set my own seed according to new information
// we overwrite our own IP number only
if ( serverCore.useStaticIP ) {
@ -263,16 +271,13 @@ public final class Protocol
} else {
final String myIP = result.get("yourip");
final String properIP = Seed.isProperIP(myIP);
mySeed.setFlagRootNode(mytype.equals(Seed.PEERTYPE_SENIOR) && responseTime < 1000 && Domains.isThisHostIP(myIP));
if ( properIP == null ) {
mySeed.setIP(myIP);
}
}
// change our seed-type
String mytype = result.get(Seed.YOURTYPE);
if ( mytype == null ) {
mytype = "";
}
final Accessible accessible = new Accessible();
if ( mytype.equals(Seed.PEERTYPE_SENIOR) || mytype.equals(Seed.PEERTYPE_PRINCIPAL) ) {
accessible.IWasAccessed = true;

@ -167,6 +167,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
private static final int FLAG_DIRECT_CONNECT = 0;
private static final int FLAG_ACCEPT_REMOTE_CRAWL = 1;
private static final int FLAG_ACCEPT_REMOTE_INDEX = 2;
private static final int FLAG_ROOT_NODE = 3;
public static final String DFLT_NETWORK_UNIT = "freeworld";
public static final String DFLT_NETWORK_GROUP = "";
@ -765,6 +766,10 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
setFlag(FLAG_ACCEPT_REMOTE_INDEX, value);
}
public final void setFlagRootNode(final boolean value) {
setFlag(FLAG_ROOT_NODE, value);
}
public final boolean getFlagDirectConnect() {
return getFlag(0);
}

Loading…
Cancel
Save