Author: ljn1981
Date: 2006-06-09 15:44:35 +0000 (Fri, 09 Jun 2006)
New Revision: 9100

Modified:
   trunk/freenet/src/freenet/node/LocationManager.java
Log:
Add in-node size estimation(logged on normal log level).
Estimated net size(session): #

Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2006-06-09 15:30:36 UTC 
(rev 9099)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2006-06-09 15:44:35 UTC 
(rev 9100)
@@ -6,6 +6,7 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Vector;
+import java.util.Date;

 import freenet.crypt.RandomSource;
 import freenet.io.comm.DMT;
@@ -968,8 +969,24 @@
         Logger.minor(this, "Known Location: "+d);
         Double dd = new Double(d);
         synchronized(knownLocs) {
-               
+            Date timestamp = new Date();
+                       //If the location is already recorded, remove it from 
the hashmap
+                       if (knownLocs.containsKey(dd)) {
+                               knownLocs.remove(dd);
+                       }
+                       //Add the location to the map with the current 
timestamp as value
+                       knownLocs.put(dd,timestamp);
+                       Logger.normal(this, "Estimated net size(session): 
"+knownLocs.size());
         }
     }

+    //Return the estimated network size for numberOfMinutes back or for the 
whole session if 0
+    public int getNetworkSizeEstimate(int numberOfMinutes) {
+               //if (numberOfMinutes == 0) {
+                       return knownLocs.size();
+               //}
+               //else {
+               //TODO: Add possibility to get an estimate based on the past 
numberOfMinutes minutes.
+               //}
+    }
 }


Reply via email to