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

Modified Files:
        CPAlgoRoutingTable.java FilterRoutingTable.java 
        NGRoutingTable.java RoutingTable.java 
Log Message:
6278:
Make Identify a (more or less) regular message. We pull the ref off it when we receive 
it, but later it gets executed by NewIdentify, which asks RT if it wants it, and if it 
does, verifies the signature (significant CPU operation!), and adds it.
Do NOT verify references on the RSL thread.
Cache fingerprint on DSAPublicKey


Index: CPAlgoRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/CPAlgoRoutingTable.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -w -r1.56 -r1.57
--- CPAlgoRoutingTable.java     21 Oct 2003 01:52:36 -0000      1.56
+++ CPAlgoRoutingTable.java     25 Oct 2003 00:45:35 -0000      1.57
@@ -74,6 +74,10 @@
     float minCP;
     int maxLookupThreads;
 
+    public boolean wantUnkeyedReference(NodeReference ref) {
+       return false;
+    }
+    
     public RTDiagSnapshot getSnapshot() {
         long nowMs = System.currentTimeMillis();
 

Index: FilterRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/FilterRoutingTable.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- FilterRoutingTable.java     22 Oct 2003 22:07:15 -0000      1.8
+++ FilterRoutingTable.java     25 Oct 2003 00:45:36 -0000      1.9
@@ -41,6 +41,10 @@
         return false;
     }
 
+    public final boolean wantUnkeyedReference(NodeReference ref) {
+       return rt.wantUnkeyedReference(ref);
+    }
+    
     public final void reference(Key k, NodeReference nr) {
         if (!blocks(nr.getIdentity()))
             rt.reference(k, nr);

Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -r1.16 -r1.17
--- NGRoutingTable.java 24 Oct 2003 04:35:41 -0000      1.16
+++ NGRoutingTable.java 25 Oct 2003 00:45:36 -0000      1.17
@@ -116,6 +116,15 @@
                }
        }
        
+       public boolean wantUnkeyedReference(NodeReference ref) {
+               Identity id = ref.getIdentity();
+               if(estimators.size() >= (maxNodes*4/5)) return false;
+               if(estimators.get(id) != null) return false;
+               if(ref.noPhysical()) return false;
+               if(!Version.checkGoodVersion(ref.getVersion(), true)) return false;
+               return true;
+       }
+       
        public synchronized void updateReference(NodeReference nr) {
                Identity i = nr.getIdentity();
                RoutingMemory mem = routingStore.getNode(i);
@@ -133,9 +142,7 @@
                } else {
                        Core.logger.log(this, "Still referencing "+nr+": 
estimators.size()="+
                                                        estimators.size()+" of 
"+maxNodes, Logger.DEBUG);
-                       if(estimators.size() < (maxNodes/2)) {
-                               if((!nr.noPhysical()) && 
Version.checkGoodVersion(nr.getVersion(), true) &&
-                                  nr.isSigned()) {
+                       if(wantUnkeyedReference(nr) && nr.isSigned()) {
                                        Core.logger.log(this, "Referencing "+nr+" to 
no key out of desperation",
                                                                        Logger.MINOR);
                                        Main.node.rt.reference(null, nr); // avoid 
referencing self FIXME
@@ -146,10 +153,6 @@
                                                                                ", 
check version="+
                                                                                
Version.checkGoodVersion(nr.getVersion(), true)+
                                                                                ", 
isSigned="+nr.isSigned(), Logger.DEBUG);
-                               }
-                       } else {
-                               Core.logger.log(this, "updateReference("+nr+") 
ignoring because size="+
-                                                               estimators.size()+" of 
"+maxNodes, Logger.DEBUG);
                        }
                }
        }

Index: RoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/RoutingTable.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- RoutingTable.java   22 Oct 2003 22:07:16 -0000      1.8
+++ RoutingTable.java   25 Oct 2003 00:45:36 -0000      1.9
@@ -10,9 +10,21 @@
 public interface RoutingTable {
 
     /**
+     * @param ref the noderef available. May be unsigned, which is why
+     * we don't immediately reference it. If we return true, verify it
+     * and then reference(null, nr) the signed version.
+     * @return if true, we want the caller to .reference(null, nr) any
+     * nodereferences it gets, regardless of source.
+     * This does not take a NodeRef because this way we can avoid verifying it
+     * if not necessary.
+     */
+    boolean wantUnkeyedReference(NodeReference ref);
+    
+    /**
      * Associates a NodeReference with a key.
      *
-     * @param k  The key to store the reference under
+     * @param k  The key to store the reference under. Null means no key, not
+     * supported by all impls.
      * @param nr  The node to associate with the key
      */
     void reference(Key k, NodeReference nr);
@@ -24,7 +36,11 @@
     boolean references(Identity id);
     
     /**
-     * Update a reference in the routing table, if there is one
+     * Update a reference in the routing table, if there is one.
+     * If there isn't one, and the reference is suitable (has a 
+     * contact address, is signed, etc), and the routing table is 
+     * short on refs, and the reference is signed, we may poach the
+     * reference.
      */
     void updateReference(NodeReference ref);
     

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

Reply via email to