Author: toad
Date: 2007-08-07 15:35:38 +0000 (Tue, 07 Aug 2007)
New Revision: 14506
Modified:
trunk/freenet/src/freenet/node/CHKInsertSender.java
trunk/freenet/src/freenet/node/FailureTableEntry.java
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/Location.java
trunk/freenet/src/freenet/node/LocationManager.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeCrypto.java
trunk/freenet/src/freenet/node/NodeDispatcher.java
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/PeerNodeStatus.java
trunk/freenet/src/freenet/node/RequestHandler.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/SSKInsertHandler.java
trunk/freenet/src/freenet/node/SSKInsertSender.java
Log:
Refactor: Don't use Location objects, just use double's for locations.
Keep some utility methods on Location.
Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertSender.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/CHKInsertSender.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -249,7 +249,7 @@
double nextValue;
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null);
if(next != null)
- nextValue = next.getLocation().getValue();
+ nextValue = next.getLocation();
else
nextValue = -1.0;
Modified: trunk/freenet/src/freenet/node/FailureTableEntry.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTableEntry.java 2007-08-07
15:04:06 UTC (rev 14505)
+++ trunk/freenet/src/freenet/node/FailureTableEntry.java 2007-08-07
15:35:38 UTC (rev 14506)
@@ -55,7 +55,7 @@
requestorBootIDs[i] = requestors[i].getBootID();
}
requestedNodes = new WeakReference[] { requested.myRef };
- requestedLocs = new double[] {
requested.getLocation().getValue() };
+ requestedLocs = new double[] { requested.getLocation() };
requestedBootIDs = new long[] { requested.getBootID() };
}
@@ -188,7 +188,7 @@
if(got == req) {
// Update existing entry
requestorIncluded = true;
- requestedLocs[j] =
req.getLocation().getValue();
+ requestedLocs[j] = req.getLocation();
requestedBootIDs[j] = req.getBootID();
requestedTimes[j] = now;
break;
@@ -209,7 +209,7 @@
if(requestedNodes[i] == null ||
requestedNodes[i].get() == null) {
PeerNode pn = requestedFrom[x++];
requestedNodes[i] = pn.myRef;
- requestedLocs[i] =
pn.getLocation().getValue();
+ requestedLocs[i] = pn.getLocation();
requestedTimes[i] = now;
if(x == ptr) break;
}
@@ -238,7 +238,7 @@
newRequestedNodes[toIndex] = pn.myRef;
newRequestedTimes[toIndex] = now;
newRequestedBootIDs[toIndex] = pn.getBootID();
- newRequestedLocs[toIndex] =
pn.getLocation().getValue();
+ newRequestedLocs[toIndex] = pn.getLocation();
toIndex++;
}
}
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/InsertHandler.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -57,7 +57,7 @@
htl = req.getShort(DMT.HTL);
closestLoc = req.getDouble(DMT.NEAREST_LOCATION);
double targetLoc = key.toNormalizedDouble();
- double myLoc = node.lm.getLocation().getValue();
+ double myLoc = node.lm.getLocation();
if(Location.distance(targetLoc, myLoc) < Location.distance(targetLoc,
closestLoc)) {
closestLoc = myLoc;
htl = node.maxHTL();
Modified: trunk/freenet/src/freenet/node/Location.java
===================================================================
--- trunk/freenet/src/freenet/node/Location.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/Location.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -13,60 +13,20 @@
* Simply a number from 0.0 to 1.0.
*/
public class Location {
- private double loc;
- private int hashCode;
-
- private Location(double location) {
- setValue(location);
- }
- public Location(String init) throws FSParseException {
- try {
- setValue(Double.parseDouble(init));
- } catch (NumberFormatException e) {
- throw new FSParseException(e);
- }
- }
-
- public double getValue() {
- return loc;
- }
-
- /**
- * @return A random Location to initialize the node to.
- */
- public static Location randomInitialLocation(RandomSource r) {
- return new Location(r.nextDouble());
- }
-
- public void setValue(double newLoc) {
- if((loc < 0.0) || (loc > 1.0))
- throw new IllegalArgumentException();
- this.loc = newLoc;
- long l = Double.doubleToLongBits(newLoc);
- hashCode = ((int)(l >>> 32)) ^ ((int)l);
- }
-
- public boolean equals(Object o) {
- if(o instanceof Location) {
- return Math.abs(((Location)o).loc - loc) <= Double.MIN_VALUE;
- }
- return false;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- /**
- * Randomize the location.
- */
- public synchronized void randomize(RandomSource r) {
- setValue(r.nextDouble());
- }
-
+ public static double getLocation(String init) throws FSParseException {
+ try {
+ if(init == null) throw new FSParseException("Null
location");
+ double d = Double.parseDouble(init);
+ if(d < 0.0 || d > 1.0) throw new
FSParseException("Invalid location "+d);
+ return d;
+ } catch (NumberFormatException e) {
+ throw new FSParseException(e);
+ }
+ }
+
static double distance(PeerNode p, double loc) {
- double d = distance(p.getLocation().getValue(), loc);
+ double d = distance(p.getLocation(), loc);
return d;
//return d * p.getBias();
}
@@ -88,4 +48,8 @@
if (a > b) return Math.min (a - b, 1.0 - a + b);
else return Math.min (b - a, 1.0 - b + a);
}
+
+ public static boolean equals(double newLoc, double currentLocation) {
+ return Math.abs(newLoc - currentLocation) < Double.MIN_VALUE *
2;
+ }
}
Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -57,14 +57,14 @@
long timeLastSuccessfullySwapped;
public LocationManager(RandomSource r) {
- loc = Location.randomInitialLocation(r);
+ loc = r.nextDouble();
sender = new SwapRequestSender();
this.r = r;
recentlyForwardedIDs = new Hashtable();
logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
- Location loc;
+ double loc;
double locChangeSession = 0.0;
int numberOfRemotePeerLocationsSeenInSwaps = 0;
@@ -72,19 +72,23 @@
/**
* @return The current Location of this node.
*/
- public Location getLocation() {
+ public double getLocation() {
return loc;
}
/**
* @param l
*/
- public void setLocation(Location l) {
+ public void setLocation(double l) {
+ if(l < 0.0 || l > 1.0) {
+ Logger.error(this, "Setting invalid location: "+l, new
Exception("error"));
+ return;
+ }
this.loc = l;
}
public void updateLocationChangeSession(double newLoc) {
- double oldLoc = this.loc.getValue();
+ double oldLoc = loc;
// Patterned after PeerManager.distance( double, double ), but also
need to know the direction of the change
if (newLoc > oldLoc) {
double directDifference = newLoc - oldLoc;
@@ -154,12 +158,12 @@
if(System.currentTimeMillis() -
timeLastSuccessfullySwapped > 30*1000) {
try {
boolean myFlag = false;
- double myLoc = loc.getValue();
+ double myLoc = loc;
PeerNode[] peers = node.peers.connectedPeers;
for(int i=0;i<peers.length;i++) {
PeerNode pn = peers[i];
if(pn.isRoutable()) {
- double ploc =
pn.getLocation().getValue();
+ double ploc = pn.getLocation();
if(Math.abs(ploc - myLoc) <=
Double.MIN_VALUE) {
myFlag = true;
// Log an ERROR
@@ -171,7 +175,7 @@
}
}
if(myFlag) {
- loc.randomize(node.random);
+ setLocation(node.random.nextDouble());
announceLocChange();
node.writeNodeFile();
}
@@ -246,7 +250,7 @@
// Create my side
long random = r.nextLong();
- double myLoc = loc.getValue();
+ double myLoc = loc;
LocationUIDPair[] friendLocsAndUIDs =
node.peers.getPeerLocationsAndUIDs();
double[] friendLocs = extractLocs(friendLocsAndUIDs);
long[] myValueLong = new long[1+1+friendLocs.length];
@@ -338,7 +342,7 @@
timeLastSuccessfullySwapped = System.currentTimeMillis();
// Swap
updateLocationChangeSession(hisLoc);
- loc.setValue(hisLoc);
+ setLocation(hisLoc);
if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <->
"+hisLoc+" - "+uid);
swaps++;
announceLocChange();
@@ -376,7 +380,7 @@
// We can't lock friends_locations, so lets just
// pretend that they're locked
long random = r.nextLong();
- double myLoc = loc.getValue();
+ double myLoc = loc;
LocationUIDPair[] friendLocsAndUIDs =
node.peers.getPeerLocationsAndUIDs();
double[] friendLocs = extractLocs(friendLocsAndUIDs);
long[] myValueLong = new long[1+1+friendLocs.length];
@@ -518,7 +522,7 @@
timeLastSuccessfullySwapped = System.currentTimeMillis();
// Swap
updateLocationChangeSession(hisLoc);
- loc.setValue(hisLoc);
+ setLocation(hisLoc);
if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <->
"+hisLoc+" - "+uid);
swaps++;
announceLocChange();
@@ -542,7 +546,7 @@
* Tell all connected peers that our location has changed
*/
private void announceLocChange() {
- Message msg = DMT.createFNPLocChangeNotification(loc.getValue());
+ Message msg = DMT.createFNPLocChangeNotification(loc);
node.peers.localBroadcast(msg, false);
}
@@ -1126,7 +1130,7 @@
public static double[] extractLocs(PeerNode[] peers, boolean
indicateBackoff) {
double[] locs = new double[peers.length];
for(int i=0;i<peers.length;i++) {
- locs[i] = peers[i].getLocation().getValue();
+ locs[i] = peers[i].getLocation();
if(indicateBackoff) {
if(peers[i].isRoutingBackedOff())
locs[i] += 1;
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2007-08-07 15:04:06 UTC (rev
14505)
+++ trunk/freenet/src/freenet/node/Node.java 2007-08-07 15:35:38 UTC (rev
14506)
@@ -421,15 +421,13 @@
swapIdentifier =
Fields.bytesToLong(darknetCrypto.identityHashHash);
String loc = fs.get("location");
- Location l;
try {
- l = new Location(loc);
+ lm.setLocation(Location.getLocation(loc));
} catch (FSParseException e) {
IOException e1 = new IOException();
e1.initCause(e);
throw e1;
}
- lm.setLocation(l);
myName = fs.get("myName");
if(myName == null) {
myName = newName();
@@ -2503,7 +2501,7 @@
}
public double getLocation() {
- return lm.loc.getValue();
+ return lm.loc;
}
public double getLocationChangeSession() {
Modified: trunk/freenet/src/freenet/node/NodeCrypto.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeCrypto.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/NodeCrypto.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -265,7 +265,7 @@
fs.putAppend("physical.udp",
ips[i].toString()); // Keep; important that node know all our IPs
}
// Negotiation types
- fs.put("location", node.lm.getLocation().getValue()); // FIXME
maybe !forSetup; see #943
+ fs.put("location", node.lm.getLocation()); // FIXME maybe
!forSetup; see #943
fs.putSingle("version", Version.getVersionString()); // Keep,
vital that peer know our version. For example, some types may be sent in
different formats to different node versions (e.g. Peer).
fs.putSingle("lastGoodVersion",
Version.getLastGoodVersionString()); // Also vital
fs.put("testnet", node.testnetEnabled); // Vital that peer know
this!
Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -325,7 +325,7 @@
// pn == null => originated locally, keep full htl
double target = m.getDouble(DMT.TARGET_LOCATION);
if(logMINOR) Logger.minor(this, "id "+id+" from "+pn+" htl
"+htl+" target "+target);
- if(Math.abs(node.lm.getLocation().getValue() - target) <=
Double.MIN_VALUE) {
+ if(Math.abs(node.lm.getLocation() - target) <=
Double.MIN_VALUE) {
if(logMINOR) Logger.minor(this, "Dispatching
"+m.getSpec()+" on "+node.getDarknetPortNumber());
// Handle locally
// Message type specific processing
@@ -633,7 +633,7 @@
best = ctx.best;
for(int i=0;i<peers.length;i++) {
- double loc = peers[i].getLocation().getValue();
+ double loc = peers[i].getLocation();
if(logMINOR) Logger.minor(this, "Location: "+loc);
// We are only interested in locations greater than the
target
if(loc <= (target + 2*Double.MIN_VALUE)) {
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -374,7 +374,7 @@
long uid;
LocationUIDPair(PeerNode pn) {
- location = pn.getLocation().getValue();
+ location = pn.getLocation();
uid = pn.swapIdentifier;
}
@@ -401,7 +401,7 @@
int x = 0;
for(int i=0;i<conns.length;i++) {
if(conns[i].isRoutable())
- locs[x++] = conns[i].getLocation().getValue();
+ locs[x++] = conns[i].getLocation();
}
// Wipe out any information contained in the order
java.util.Arrays.sort(locs, 0, x);
@@ -513,7 +513,7 @@
PeerNode p = peers[i];
if(!p.isRoutable()) continue;
if(p.isRoutingBackedOff()) continue;
- double peerloc = p.getLocation().getValue();
+ double peerloc = p.getLocation();
if(Math.abs(peerloc - ignoreLoc) < Double.MIN_VALUE*2)
continue;
double diff = Location.distance(peerloc, loc);
@@ -528,7 +528,7 @@
PeerNode p = peers[i];
if(!p.isRoutable()) continue;
// Ignore backoff state
- double peerloc = p.getLocation().getValue();
+ double peerloc = p.getLocation();
if(Math.abs(peerloc - ignoreLoc) < Double.MIN_VALUE*2)
continue;
double diff = Location.distance(peerloc, loc);
@@ -543,7 +543,7 @@
}
public boolean isCloserLocation(double loc) {
- double nodeLoc = node.lm.getLocation().getValue();
+ double nodeLoc = node.lm.getLocation();
double nodeDist = Location.distance(nodeLoc, loc);
double closest = closestPeerLocation(loc, nodeLoc);
if(closest > 1.0) {
@@ -569,7 +569,7 @@
if (calculateMisrouting) {
PeerNode nbo = _closerPeer(pn, routedTo, notIgnored, loc,
ignoreSelf, true, minVersion, null, maxDistance);
if(nbo != null) {
-
node.nodeStats.routingMissDistance.report(Location.distance(best,
nbo.getLocation().getValue()));
+
node.nodeStats.routingMissDistance.report(Location.distance(best,
nbo.getLocation()));
int numberOfConnected =
getPeerNodeStatusSize(PEER_NODE_STATUS_CONNECTED);
int numberOfRoutingBackedOff =
getPeerNodeStatusSize(PEER_NODE_STATUS_ROUTING_BACKED_OFF);
if (numberOfRoutingBackedOff + numberOfConnected > 0 ) {
@@ -603,7 +603,7 @@
double bestDiff = Double.MAX_VALUE;
double maxDiff = 0.0;
if(!ignoreSelf)
- maxDiff = Location.distance(node.lm.getLocation().getValue(),
target);
+ maxDiff = Location.distance(node.lm.getLocation(), target);
PeerNode best = null;
double bestLoc = -2;
int count = 0;
@@ -632,17 +632,17 @@
count++;
double diff = Location.distance(p, target);
if(diff > maxDistance) continue;
- if(logMINOR) Logger.minor(this,
"p.loc="+p.getLocation().getValue()+", target="+target+",
d="+Location.distance(p.getLocation().getValue(), target)+" usedD="+diff+" for
"+p.getPeer());
+ if(logMINOR) Logger.minor(this, "p.loc="+p.getLocation()+",
target="+target+", d="+Location.distance(p.getLocation(), target)+"
usedD="+diff+" for "+p.getPeer());
if((!ignoreSelf) && (diff > maxDiff)) {
if(logMINOR) Logger.minor(this, "Ignoring because
>maxDiff="+maxDiff);
continue;
}
- double loc = p.getLocation().getValue();
+ double loc = p.getLocation();
if(diff < bestDiff) {
bestLoc = loc;
best = p;
bestDiff = diff;
- if(logMINOR) Logger.minor(this, "New best: "+diff+"
("+p.getLocation().getValue()+" for "+p.getPeer());
+ if(logMINOR) Logger.minor(this, "New best: "+diff+"
("+p.getLocation()+" for "+p.getPeer());
}
if(addUnpickedLocsTo != null) {
Double d = new Double(loc);
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -151,7 +151,7 @@
private static final int MAX_HANDSHAKE_COUNT = 2;
/** Current location in the keyspace */
- private Location currentLocation;
+ private double currentLocation;
/** Node identity; for now a block of data, in future a
* public key (FIXME). Cannot be changed.
@@ -340,8 +340,7 @@
version = fs.get("version");
Version.seenVersion(version);
String locationString = fs.get("location");
- if(locationString == null) throw new FSParseException("No location");
- currentLocation = new Location(locationString);
+ currentLocation = Location.getLocation(locationString);
// FIXME make mandatory once everyone has upgraded
lastGoodVersion = fs.get("lastGoodVersion");
@@ -375,7 +374,7 @@
throw new FSParseException(e1);
}
if(nominalPeer.isEmpty()) {
- Logger.normal(this, "No IP addresses found for identity
'"+Base64.encode(identity)+"', possibly at location
'"+Double.toString(currentLocation.getValue())+": "+userToString());
+ Logger.normal(this, "No IP addresses found for identity
'"+Base64.encode(identity)+"', possibly at location
'"+Double.toString(currentLocation)+": "+userToString());
detectedPeer = null;
} else {
detectedPeer = (Peer) nominalPeer.firstElement();
@@ -803,7 +802,7 @@
/**
* What is my current keyspace location?
*/
- public synchronized Location getLocation() {
+ public synchronized double getLocation() {
return currentLocation;
}
@@ -1238,8 +1237,13 @@
*/
public void updateLocation(double newLoc) {
logMINOR = Logger.shouldLog(Logger.MINOR, PeerNode.class);
+ if(newLoc < 0.0 || newLoc > 1.0) {
+ Logger.error(this, "Invalid location update for "+this, new
Exception("error"));
+ // Ignore it
+ return;
+ }
synchronized(this) {
- currentLocation.setValue(newLoc);
+ currentLocation = newLoc;
}
node.peers.writePeers();
}
@@ -1539,7 +1543,7 @@
* Send any high level messages that need to be sent on connect.
*/
private void sendInitialMessages() {
- Message locMsg =
DMT.createFNPLocChangeNotification(node.lm.loc.getValue());
+ Message locMsg = DMT.createFNPLocChangeNotification(node.lm.loc);
Message ipMsg = DMT.createFNPDetectedIPAddress(detectedPeer);
Message timeMsg = DMT.createFNPTime(System.currentTimeMillis());
@@ -1713,9 +1717,11 @@
if(!forARK)
throw new FSParseException("No location");
} else {
- Location loc = new Location(locationString);
- if(!loc.equals(currentLocation)) changedAnything = true;
- currentLocation = loc;
+ double newLoc = Location.getLocation(locationString);
+ if(!Location.equals(newLoc, currentLocation)) {
+ changedAnything = true;
+ currentLocation = newLoc;
+ }
}
Vector oldNominalPeer = nominalPeer;
@@ -1829,7 +1835,7 @@
}
if((getPeerNodeStatus() ==
PeerManager.PEER_NODE_STATUS_NEVER_CONNECTED) && (getPeerAddedTime() > 1))
idle = (int) ((now - getPeerAddedTime()) / 1000);
- return String.valueOf(getPeer())+ '\t' +getIdentityString()+ '\t'
+getLocation().getValue()+ '\t' +getPeerNodeStatusString()+ '\t' +idle;
+ return String.valueOf(getPeer())+ '\t' +getIdentityString()+ '\t'
+getLocation()+ '\t' +getPeerNodeStatusString()+ '\t' +idle;
}
public String getFreevizOutput() {
@@ -1923,7 +1929,7 @@
}
fs.put("auth.negTypes", negTypes);
fs.putSingle("identity", getIdentityString());
- fs.putSingle("location", Double.toString(currentLocation.getValue()));
+ fs.putSingle("location", Double.toString(currentLocation));
fs.putSingle("testnet", Boolean.toString(testnetEnabled));
fs.putSingle("version", version);
if(peerCryptoGroup != null)
Modified: trunk/freenet/src/freenet/node/PeerNodeStatus.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNodeStatus.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/PeerNodeStatus.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -92,7 +92,7 @@
this.statusValue = peerNode.getPeerNodeStatus();
this.statusName = peerNode.getPeerNodeStatusString();
this.statusCSSName = peerNode.getPeerNodeStatusCSSClassName();
- this.location = peerNode.getLocation().getValue();
+ this.location = peerNode.getLocation();
this.version = peerNode.getVersion();
this.simpleVersion = peerNode.getSimpleVersion();
this.routingBackoffLength = peerNode.getRoutingBackoffLength();
Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/RequestHandler.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -54,7 +54,7 @@
htl = req.getShort(DMT.HTL);
source = (PeerNode) req.getSource();
closestLoc = req.getDouble(DMT.NEAREST_LOCATION);
- double myLoc = n.lm.getLocation().getValue();
+ double myLoc = n.lm.getLocation();
key = (Key) req.getObject(DMT.FREENET_ROUTING_KEY);
double keyLoc = key.toNormalizedDouble();
if(Location.distance(keyLoc, myLoc) < Location.distance(keyLoc,
closestLoc)) {
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -142,7 +142,7 @@
double nextValue;
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null);
if(next != null)
- nextValue = next.getLocation().getValue();
+ nextValue = next.getLocation();
else
nextValue = -1.0;
Modified: trunk/freenet/src/freenet/node/SSKInsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/SSKInsertHandler.java 2007-08-07
15:04:06 UTC (rev 14505)
+++ trunk/freenet/src/freenet/node/SSKInsertHandler.java 2007-08-07
15:35:38 UTC (rev 14506)
@@ -55,7 +55,7 @@
htl = req.getShort(DMT.HTL);
closestLoc = req.getDouble(DMT.NEAREST_LOCATION);
double targetLoc = key.toNormalizedDouble();
- double myLoc = node.lm.getLocation().getValue();
+ double myLoc = node.lm.getLocation();
if(Location.distance(targetLoc, myLoc) < Location.distance(targetLoc,
closestLoc)) {
closestLoc = myLoc;
htl = node.maxHTL();
Modified: trunk/freenet/src/freenet/node/SSKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/SSKInsertSender.java 2007-08-07 15:04:06 UTC
(rev 14505)
+++ trunk/freenet/src/freenet/node/SSKInsertSender.java 2007-08-07 15:35:38 UTC
(rev 14506)
@@ -139,7 +139,7 @@
synchronized(node.peers) {
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null);
if(next != null)
- nextValue = next.getLocation().getValue();
+ nextValue = next.getLocation();
else
nextValue = -1.0;
}