Author: nextgens
Date: 2008-07-17 13:01:49 +0000 (Thu, 17 Jul 2008)
New Revision: 21165
Modified:
trunk/freenet/src/freenet/node/PeerManager.java
Log:
Second part of the FOAF routing changes: the routing algorithm now takes our
peer's peers location into account
REVIEW IT!
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2008-07-17 12:57:45 UTC
(rev 21164)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2008-07-17 13:01:49 UTC
(rev 21165)
@@ -880,6 +880,20 @@
//To help avoid odd race conditions, get the location
only once and use it for all calculations.
double loc = p.getLocation();
double diff = Location.distance(loc, target);
+
+ double[] peersLocation = p.getPeersLocation();
+ if(peersLocation != null) {
+ for(double l : peersLocation) {
+ double newDiff = Location.distance(l,
target);
+ if(newDiff < diff) {
+ loc = l;
+ diff = newDiff;
+ }
+ }
+ if(logMINOR)
+ Logger.minor(this, "The peer "+p+" has
published his peer's locations and the closest we have found to the target is
"+diff+" away.");
+ }
+
if(diff > maxDistance)
continue;
if((!ignoreSelf) && (diff > maxDiff)) {