Author: nextgens
Date: 2008-09-01 21:16:30 +0000 (Mon, 01 Sep 2008)
New Revision: 22322

Modified:
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerManager.java
Log:
Enable FOAF by default; wire-in the mitigation code (yes, the current 
implementation is slow!)

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-09-01 21:06:50 UTC (rev 
22321)
+++ trunk/freenet/src/freenet/node/Node.java    2008-09-01 21:16:30 UTC (rev 
22322)
@@ -919,7 +919,7 @@
                });
                enableSwapping = nodeConfig.getBoolean("enableSwapping");

-               nodeConfig.register("publishOurPeersLocation", false, 
sortOrder++, true, false, "Node.publishOurPeersLocation", 
"Node.publishOurPeersLocationLong", new BooleanCallback() {
+               nodeConfig.register("publishOurPeersLocation", true, 
sortOrder++, true, false, "Node.publishOurPeersLocation", 
"Node.publishOurPeersLocationLong", new BooleanCallback() {

                        public Boolean get() {
                                return publishOurPeersLocation;
@@ -931,7 +931,7 @@
                });
                publishOurPeersLocation = 
nodeConfig.getBoolean("publishOurPeersLocation");

-               nodeConfig.register("routeAccordingToOurPeersLocation", false, 
sortOrder++, true, false, "Node.routeAccordingToOurPeersLocation", 
"Node.routeAccordingToOurPeersLocationLong", new BooleanCallback() {
+               nodeConfig.register("routeAccordingToOurPeersLocation", true, 
sortOrder++, true, false, "Node.routeAccordingToOurPeersLocation", 
"Node.routeAccordingToOurPeersLocationLong", new BooleanCallback() {

                        public Boolean get() {
                                return routeAccordingToOurPeersLocation;

Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java     2008-09-01 21:06:50 UTC 
(rev 22321)
+++ trunk/freenet/src/freenet/node/PeerManager.java     2008-09-01 21:16:30 UTC 
(rev 22322)
@@ -881,6 +881,9 @@

                long now = System.currentTimeMillis();
                int count = 0;
+               
+               Long selectionSamplesTimestamp = now - 
PeerNode.SELECTION_SAMPLING_PERIOD;
+               int numberOfSelectionsSamples = 
getNumberOfSelectionSamples().tailSet(selectionSamplesTimestamp).size();
                for(int i = 0; i < peers.length; i++) {
                        PeerNode p = peers[i];
                        if(routedTo.contains(p)) {
@@ -903,6 +906,14 @@
                                        Logger.minor(this, "Skipping old 
version: " + p.getPeer());
                                continue;
                        }
+                       int selectionSamples = 
p.getNumberOfSelections().tailSet(selectionSamplesTimestamp).size();
+                       int selectionSamplesPercentage = 
selectionSamples*100/numberOfSelectionsSamples;
+                       if(PeerNode.SELECTION_PERCENTAGE_WARNING < 
selectionSamplesPercentage) {
+                               if(logMINOR)
+                                       Logger.minor(this, "Skipping 
over-selectionned peer("+selectionSamplesPercentage+"%): "+p.getPeer());
+                               continue;
+                       }
+                       
                        long timeout = -1;
                        if(entry != null)
                                timeout = entry.getTimeoutTime(p);
@@ -912,7 +923,7 @@
                        double diff = Location.distance(loc, target);

                        double[] peersLocation = p.getPeersLocation();
-                       if((node.shallWeRouteAccordingToOurPeersLocation()) && 
(peersLocation != null)) {
+                       if((peersLocation != null) && 
(node.shallWeRouteAccordingToOurPeersLocation())) {
                                for(double l : peersLocation) {
                                        double newDiff = Location.distance(l, 
target);
                                        if(newDiff < diff) {


Reply via email to