Update of /cvsroot/freenet/freenet/src/freenet/node
In directory sc8-pr-cvs1:/tmp/cvs-serv5586/src/freenet/node

Modified Files:
        Node.java LoadStats.java Main.java NodeConsole.java 
        ConnectionOpener.java 
Log Message:
Work around problem with ThrottleAsyncEntropyYarrow/Yarrow initialization order.
Made randSource in Core private and started exposing it though a getter instead of 
directly.

Index: Node.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Node.java,v
retrieving revision 1.231
retrieving revision 1.232
diff -u -w -r1.231 -r1.232
--- Node.java   26 Oct 2003 07:36:40 -0000      1.231
+++ Node.java   27 Oct 2003 14:45:16 -0000      1.232
@@ -2779,9 +2779,9 @@
     }
     
     public static int perturbHTL(int htl) {
-        float f = randSource.nextFloat();
+        float f = getRandSource().nextFloat();
         if(htl>3 && (htl/maxHopsToLive) > f) {
-            f = randSource.nextFloat();
+            f = getRandSource().nextFloat();
             if(f < (1/5)) htl+=2;
             else if(f < (2/5)) htl+=1;
             else if(f < (3/5)) htl+=0;
@@ -2810,7 +2810,7 @@
                        "out of maximum "+storeSize, Logger.DEBUG);
             return true;
         }
-        if(sd.shouldCache(randSource, cacheProbPerHop)) {
+        if(sd.shouldCache(getRandSource(), cacheProbPerHop)) {
             logger.log(this, "shouldCache returning true because "+
                        "sd.shouldCache says so for "+sd, Logger.DEBUG);
             return true;
@@ -2840,7 +2840,7 @@
                            Logger.DEBUG);
                 return true;
             } else {
-                if(sd.shouldCache(randSource, cacheProbPerHop)) {
+                if(sd.shouldCache(getRandSource(), cacheProbPerHop)) {
                     logger.log(this, "shouldReference returning true because "+
                                "sd.shouldCache says so for "+sd, Logger.DEBUG);
                     return true;

Index: LoadStats.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/LoadStats.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -w -r1.34 -r1.35
--- LoadStats.java      19 Oct 2003 23:27:36 -0000      1.34
+++ LoadStats.java      27 Oct 2003 14:45:16 -0000      1.35
@@ -459,7 +459,7 @@
      * This respects the setting of Node.doLoadBalance.
      */
     public final boolean shouldReset() {
-        float p = Node.randSource.nextFloat();
+        float p = Node.getRandSource().nextFloat();
         boolean b = ((Node.doLoadBalance && p < resetProbability) ||
                      (!Node.doLoadBalance && p < defaultResetProbability));
         if (b)

Index: Main.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/Main.java,v
retrieving revision 1.281
retrieving revision 1.282
diff -u -w -r1.281 -r1.282
--- Main.java   25 Oct 2003 18:28:00 -0000      1.281
+++ Main.java   27 Oct 2003 14:45:16 -0000      1.282
@@ -750,7 +750,7 @@
                                            Node.minARKDelay,
                                            Node.minCP,
                                            maxARKLookups,
-                                           Core.randSource);
+                                           Core.getRandSource());
                 
                 rt = cprt;
             } else if(Node.routingTableImpl.equalsIgnoreCase("ng")) {
@@ -1116,7 +1116,7 @@
             System.runFinalization();
             e.printStackTrace(System.err);
         } finally {
-            Core.randSource.close();
+            Core.getRandSource().close();
         }
     }
     
@@ -1327,7 +1327,7 @@
                             Logger.NORMAL);
             try {
                 long t = System.currentTimeMillis();
-                fs.initialize(Node.randSource, this);
+                fs.initialize(Node.getRandSource(), this);
                 t = System.currentTimeMillis() - t;
                 Node.logger.log(this, "finished initializing store ("+(t/1000)+" 
sec)",
                                 Logger.NORMAL);
@@ -2305,7 +2305,7 @@
                 v.copyInto(ret);
                 // shuffle
                 for (int j = ret.length - 1 ; j > 0 ; j--) {
-                    int k = (int) ((j + 1) * Core.randSource.nextFloat());
+                    int k = (int) ((j + 1) * Core.getRandSource().nextFloat());
                     NodeReference temp = ret[k];
                     ret[k] = ret[j];
                     ret[j] = temp;
@@ -2336,7 +2336,7 @@
         Core.logger.log(Main.class, "Seeding Routing Table: "+nodes.length+
                         " nodes", Core.logger.DEBUG);
         for (int i=0; i<nodes.length; ++i) {
-            int x = Core.randSource.nextInt() % n.size();
+            int x = Core.getRandSource().nextInt() % n.size();
             if(x < 0) x = -x;
             NodeReference ref = (NodeReference)(n.elementAt(x));
             n.remove(x);
@@ -2344,7 +2344,7 @@
             if (force || !rt.references(ref.getIdentity())) {
                 Core.logger.log(Main.class, "Doing node "+i, 
                                 Core.logger.DEBUG);
-                int r = Core.randSource.nextInt();
+                int r = Core.getRandSource().nextInt();
                 int c = ref.hashCode();
                 byte[] k = new byte[18];
                 for (int j=0; j<16; ++j)
@@ -2550,12 +2550,12 @@
                         Logger.NORMAL);
     
         // FIXME: nodes should generate their own DSA group
-        privateKey = new DSAAuthentity(Global.DSAgroupC, Node.randSource);
+        privateKey = new DSAAuthentity(Global.DSAgroupC, Node.getRandSource());
         if (cipher != null) {
             cipherKey = new byte[cipher.getKeySize() >> 3];
             baseIV = new byte[cipher.getBlockSize() >> 3];
-            Node.randSource.nextBytes(cipherKey);
-            Node.randSource.nextBytes(baseIV);
+            Node.getRandSource().nextBytes(cipherKey);
+            Node.getRandSource().nextBytes(baseIV);
         }
         newARK();
         initialARKversion = 0;
@@ -2565,7 +2565,7 @@
     public static void newARK() {
         ARKversion = 0;
         ARKcrypt = new byte[32]; // FIXME!
-        Node.randSource.nextBytes(ARKcrypt);
+        Node.getRandSource().nextBytes(ARKcrypt);
     }
     
     public static void writeNodeFile() throws IOException {
@@ -3094,7 +3094,7 @@
         long startTime = System.currentTimeMillis();
         for(int x=0;x<1000;x++) {
             long enteredTime = System.currentTimeMillis();
-            BigInteger rand = new BigInteger(256, Core.randSource);
+            BigInteger rand = new BigInteger(256, Core.getRandSource());
             long gotRandTime = System.currentTimeMillis();
             Core.logger.log(Main.class, "Got random in "+(gotRandTime - enteredTime),
                             Core.logger.DEBUG);

Index: NodeConsole.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/NodeConsole.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- NodeConsole.java    19 Jun 2003 13:31:19 -0000      1.5
+++ NodeConsole.java    27 Oct 2003 14:45:17 -0000      1.6
@@ -175,7 +175,7 @@
             out.print("<td align=\"center\">");
             if (node.interfaces[i].getExceptionCount() > 0) {
                 // keep link fresh
-                String t = Fields.longToHex(node.randSource.nextLong());
+                String t = Fields.longToHex(node.getRandSource().nextLong());
                 out.print("<a href=\"?show_errors="+i+"&t="+t+"\">");
                 out.print(node.interfaces[i].getExceptionCount());
                 out.print("</a>");

Index: ConnectionOpener.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/ConnectionOpener.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -w -r1.23 -r1.24
--- ConnectionOpener.java       26 Oct 2003 02:06:09 -0000      1.23
+++ ConnectionOpener.java       27 Oct 2003 14:45:17 -0000      1.24
@@ -205,7 +205,7 @@
            baseBackoffDelay = startBackoffDelay;
        
        currentDelay = baseBackoffDelay + 
-           Core.randSource.nextInt(baseBackoffDelay);
+           Core.getRandSource().nextInt(baseBackoffDelay);
 
        baseBackoffDelay <<= 1;
        

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to