Author: zothar
Date: 2008-01-06 22:09:05 +0000 (Sun, 06 Jan 2008)
New Revision: 16952

Modified:
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Support differential node references in parseARK

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-01-06 21:51:17 UTC 
(rev 16951)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-01-06 22:09:05 UTC 
(rev 16952)
@@ -646,18 +646,25 @@
                USK ark = null;
                long arkNo = 0;
                try {
+                       String arkPubKey = fs.get("ark.pubURI");
                        arkNo = fs.getLong("ark.number", -1);
-                       if(arkNo != -1) {
+                       if(arkPubKey != null && arkNo != -1) {
                                if(onStartup) arkNo++;
                                // this is the number of the ref we are parsing.
                                // we want the number of the next edition.
                                // on startup we want to fetch the old edition 
in case there's been a corruption.
-                               String arkPubKey = fs.get("ark.pubURI");
-                               if(arkPubKey != null) {
                                        FreenetURI uri = new 
FreenetURI(arkPubKey);
                                        ClientSSK ssk = new ClientSSK(uri);
                                        ark = new USK(ssk, arkNo);
-                               }
+                       } else if(forDiffNodeRef && arkPubKey == null && myARK 
!= null) {
+                               // get the ARK URI from the previous ARK and 
the edition from the SFS
+                               FreenetURI uri = myARK.getURI();
+                               ClientSSK ssk = new ClientSSK(uri);
+                               ark = new USK(ssk, arkNo);
+                       } else if(forDiffNodeRef && arkPubKey != null && myARK 
!= null) {
+                               // the SFS must contain an edition if it 
contains a arkPubKey
+                               Logger.error(this, "Got a differential node 
reference from " + this + " with an arkPubKey but no ARK edition");
+                               return false;
                        } else return false;
                } catch(MalformedURLException e) {
                        Logger.error(this, "Couldn't parse ARK info for " + 
this + ": " + e, e);


Reply via email to