Author: toad
Date: 2007-12-04 18:20:37 +0000 (Tue, 04 Dec 2007)
New Revision: 16271

Modified:
   trunk/freenet/src/freenet/node/AnnounceSender.java
Log:
Implement sendOurRef() and call it from the right places

Modified: trunk/freenet/src/freenet/node/AnnounceSender.java
===================================================================
--- trunk/freenet/src/freenet/node/AnnounceSender.java  2007-12-04 18:14:40 UTC 
(rev 16270)
+++ trunk/freenet/src/freenet/node/AnnounceSender.java  2007-12-04 18:20:37 UTC 
(rev 16271)
@@ -289,6 +289,7 @@
                        try {
                                OpennetPeerNode pn = node.addNewOpennetNode(fs);
                                cb.addedNode(pn);
+                               sendOurRef(source);
                        } catch (FSParseException e) {
                                Logger.normal(this, "Failed to parse reply: 
"+e, e);
                                if(cb != null) cb.bogusNoderef("parse failed: 
"+e);
@@ -298,6 +299,11 @@
                        } catch (ReferenceSignatureVerificationException e) {
                                Logger.normal(this, "Failed to parse reply: 
"+e, e);
                                if(cb != null) cb.bogusNoderef("parse failed: 
"+e);
+                       } catch (NotConnectedException e) {
+                               Logger.normal(this, "Added their ref but then 
lost connection");
+                               // It will be dropped soon. :(
+                               // FIXME maybe we should remove it here.
+                               return false;
                        }
                }
                return true;
@@ -361,30 +367,11 @@
                        om.rejectRef(uid, source, DMT.NODEREF_REJECTED_INVALID, 
this);
                        return false;
                }
-               // If we want it, add it and send it.
-               try {
-                       if(om.addNewOpennetNode(fs) != null) {
-                               sendOurRef();
-                       } else {
-                               // Okay, just route it.
-                       }
-               } catch (FSParseException e) {
-                       om.rejectRef(uid, source, DMT.NODEREF_REJECTED_INVALID, 
this);
-                       return false;
-               } catch (PeerParseException e) {
-                       om.rejectRef(uid, source, DMT.NODEREF_REJECTED_INVALID, 
this);
-                       return false;
-               } catch (ReferenceSignatureVerificationException e) {
-                       om.rejectRef(uid, source, DMT.NODEREF_REJECTED_INVALID, 
this);
-                       return false;
-               }
                return true;
        }

-       private void sendOurRef() {
-               // FIXME transmit our noderef back to the node
-               // TODO Auto-generated method stub
-               
+       private void sendOurRef(PeerNode next) throws NotConnectedException {
+               om.sendAnnouncementReply(uid, next, 
om.crypto.myCompressedFullRef(), this);
        }

        private volatile Object totalBytesSync = new Object();


Reply via email to