Author: dbkr
Date: 2006-04-21 21:06:30 +0000 (Fri, 21 Apr 2006)
New Revision: 8563

Modified:
   trunk/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
   trunk/freenet/src/freenet/keys/SSKBlock.java
   trunk/freenet/src/freenet/node/Version.java
Log:
650: Make collisions work


Modified: trunk/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
===================================================================
--- trunk/freenet/src/freenet/client/async/MultiPutCompletionCallback.java      
2006-04-21 15:35:47 UTC (rev 8562)
+++ trunk/freenet/src/freenet/client/async/MultiPutCompletionCallback.java      
2006-04-21 21:06:30 UTC (rev 8563)
@@ -37,7 +37,13 @@
                        if(!(waitingFor.isEmpty() && started))
                                return;
                }
-               complete(null);
+               /* Using this.e here will cause complete to consider the
+                * insert as failed if onFailed has been called in the past
+                * for this request. This makes collisions work. It does
+                * mean that onSuccess gets called, and then we consider
+                * the insert to have failed, which may or may not make sense.
+                */
+               complete(this.e);
        }

        public void onFailure(InserterException e, ClientPutState state) {

Modified: trunk/freenet/src/freenet/keys/SSKBlock.java
===================================================================
--- trunk/freenet/src/freenet/keys/SSKBlock.java        2006-04-21 15:35:47 UTC 
(rev 8562)
+++ trunk/freenet/src/freenet/keys/SSKBlock.java        2006-04-21 21:06:30 UTC 
(rev 8563)
@@ -15,7 +15,10 @@
  * decode original data when fed a ClientSSK.
  */
 public class SSKBlock implements KeyBlock {
-
+       // how much of the headers we compare in order to consider two
+       // SSKBlocks equal - necessary because the last 64 bytes need not
+       // be the same for the same data and the same key (see comments below)
+       private static final int HEADER_COMPARE_TO = 71;
        final byte[] data;
        final byte[] headers;
        /** The index of the first byte of encrypted fields in the headers, 
after E(H(docname)) */
@@ -63,7 +66,11 @@
        if(block.headersOffset != headersOffset) return false;
        if(block.hashIdentifier != hashIdentifier) return false;
        if(block.symCipherIdentifier != symCipherIdentifier) return false;
-       if(!Arrays.equals(block.headers, headers)) return false;
+       // only compare some of the headers (see top)
+       for (int i = 0; i < HEADER_COMPARE_TO; i++) {
+               if (block.headers[i] != headers[i]) return false;
+       }
+       //if(!Arrays.equals(block.headers, headers)) return false;
        if(!Arrays.equals(block.data, data)) return false;
        return true;
     }

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-04-21 15:35:47 UTC (rev 
8562)
+++ trunk/freenet/src/freenet/node/Version.java 2006-04-21 21:06:30 UTC (rev 
8563)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 649;
+       private static final int buildNumber = 650;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 591;


Reply via email to