[freenet-cvs] r14507 - trunk/freenet/src/freenet/node

toad at freenetproject.org toad at freenetproject.org
Tue Aug 7 15:38:20 UTC 2007


Author: toad
Date: 2007-08-07 15:38:20 +0000 (Tue, 07 Aug 2007)
New Revision: 14507

Modified:
   trunk/freenet/src/freenet/node/LocationManager.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Encapsulate LocationManager.loc/locChangeSession - make them private, use accessors, synchronize to access.

Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java	2007-08-07 15:35:38 UTC (rev 14506)
+++ trunk/freenet/src/freenet/node/LocationManager.java	2007-08-07 15:38:20 UTC (rev 14507)
@@ -64,22 +64,22 @@
         logMINOR = Logger.shouldLog(Logger.MINOR, this);
     }
 
-    double loc;
-    double locChangeSession = 0.0;
+    private double loc;
+    private double locChangeSession = 0.0;
     
     int numberOfRemotePeerLocationsSeenInSwaps = 0;
 
     /**
      * @return The current Location of this node.
      */
-    public double getLocation() {
+    public synchronized double getLocation() {
         return loc;
     }
 
     /**
      * @param l
      */
-    public void setLocation(double l) {
+    public synchronized void setLocation(double l) {
     	if(l < 0.0 || l > 1.0) {
     		Logger.error(this, "Setting invalid location: "+l, new Exception("error"));
     		return;
@@ -1147,4 +1147,8 @@
 			uids[i] = peers[i].swapIdentifier;
 		return uids;
 	}
+
+	public synchronized double getLocChangeSession() {
+		return locChangeSession;
+	}
 }

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java	2007-08-07 15:35:38 UTC (rev 14506)
+++ trunk/freenet/src/freenet/node/Node.java	2007-08-07 15:38:20 UTC (rev 14507)
@@ -2501,11 +2501,11 @@
 	}
 
 	public double getLocation() {
-		return lm.loc;
+		return lm.getLocation();
 	}
 
 	public double getLocationChangeSession() {
-		return lm.locChangeSession;
+		return lm.getLocChangeSession();
 	}
 	
 	public int getNumberOfRemotePeerLocationsSeenInSwaps() {

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java	2007-08-07 15:35:38 UTC (rev 14506)
+++ trunk/freenet/src/freenet/node/PeerNode.java	2007-08-07 15:38:20 UTC (rev 14507)
@@ -1543,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);
+        Message locMsg = DMT.createFNPLocChangeNotification(node.lm.getLocation());
         Message ipMsg = DMT.createFNPDetectedIPAddress(detectedPeer);
         Message timeMsg = DMT.createFNPTime(System.currentTimeMillis());
         




More information about the cvs mailing list