[freenet-cvs] r20646 - branches/saltedhashstore/freenet/src/freenet/store

j16sdiz at freenetproject.org j16sdiz at freenetproject.org
Tue Jun 24 14:29:11 UTC 2008


Author: j16sdiz
Date: 2008-06-24 14:29:10 +0000 (Tue, 24 Jun 2008)
New Revision: 20646

Modified:
   branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
Log:
add "generation" (perpare for better filter rebuild and key count)


Modified: branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
===================================================================
--- branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java	2008-06-24 14:28:47 UTC (rev 20645)
+++ branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java	2008-06-24 14:29:10 UTC (rev 20646)
@@ -76,6 +76,7 @@
 	private final int dataBlockLength;
 	private final Random random;
 	private long storeSize;
+	private byte generation;
 
 	public static SaltedHashFreenetStore construct(File baseDir, String name, StoreCallback callback, Random random,
 			long maxKeys, SemiOrderedShutdownHook shutdownHook) throws IOException {
@@ -305,7 +306,7 @@
 
 	/**
 	 * Data entry
-	 *
+	 * 
 	 * <pre>
 	 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 *       |0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|
@@ -320,9 +321,9 @@
 	 *  +----+---------------+---------------+
 	 *  |0040|       Plain Routing Key       |
 	 *  |0050| (Only if ENTRY_FLAG_PLAINKEY) |
-	 *  +----+-------------------------------+
-	 *  |0060|            Reserved           |
-	 *  +----+-------------------------------+
+	 *  +----+-+-----------------------------+
+	 *  |0060|G|          Reserved           |
+	 *  +----+-+-----------------------------+
 	 *  |0070|       Encrypted Header        |
 	 *  |  . + - - - - - - - - - - - - - - - +
 	 *  |  . |        Encrypted Data         |
@@ -330,7 +331,7 @@
 	 *  |    |           Padding             |
 	 *  +----+-------------------------------+
 	 * </pre>
-	 *
+	 * 
 	 * Total length is padded to multiple of 512bytes. All reserved bytes should be zero when
 	 * written, ignored on read.
 	 */
@@ -340,11 +341,13 @@
 		private byte[] dataEncryptIV;
 		private long flag;
 		private long storeSize;
+		private byte generation;
 		private byte[] header;
 		private byte[] data;
-
+		
 		private boolean isEncrypted;
 		public long curOffset = -1;
+		
 
 		/**
 		 * Create a new entry
@@ -358,6 +361,7 @@
 
 			flag = ENTRY_FLAG_OCCUPIED;
 			storeSize = SaltedHashFreenetStore.this.storeSize;
+			generation = SaltedHashFreenetStore.this.generation;
 
 			// header/data will be overwritten in encrypt()/decrypt(),
 			// let's make a copy here
@@ -405,6 +409,9 @@
 				in.get(plainRoutingKey);
 			}
 
+			in.position(0x60);
+			generation = in.get();
+			
 			// reserved bytes
 			in.position((int) ENTRY_HEADER_LENGTH);
 
@@ -431,7 +438,10 @@
 			if (OPTION_SAVE_PLAINKEY && plainRoutingKey != null) {
 				out.put(plainRoutingKey);
 			}
-
+			
+			out.position(0x60);
+			out.put(generation);
+			
 			// reserved bytes
 			out.position((int) ENTRY_HEADER_LENGTH);
 
@@ -753,7 +763,7 @@
 	// ------------- Configuration
 	/**
 	 * Configuration File
-	 *
+	 * 
 	 * <pre>
 	 *       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 *       |0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|
@@ -761,9 +771,11 @@
 	 *  |0000|             Salt              |
 	 *  +----+---------------+---------------+
 	 *  |0010|   Store Size  | prevStoreSize |
-	 *  +----+---------------+---------------+
-	 *  |0010| Est Key Count |    reserved   |
-	 *  +----+---------------+---------------+
+	 *  +----+---------------+-+-------------+
+	 *  |0020| Est Key Count |G|  reserved   |
+	 *  +----+---------------+-+-------------+
+	 *  
+	 *  G = Generation
 	 * </pre>
 	 */
 	private final File configFile;
@@ -789,7 +801,7 @@
 			storeSize = raf.readLong();
 			prevStoreSize = raf.readLong();
 			keyCount.set(raf.readLong());
-			raf.readLong();
+			generation = raf.readByte();
 
 			raf.close();
 		}
@@ -810,7 +822,8 @@
 			raf.writeLong(storeSize);
 			raf.writeLong(prevStoreSize);
 			raf.writeLong(keyCount.get());
-			raf.writeLong(0);
+			raf.write(generation);
+			raf.setLength(0x30);
 
 			raf.close();
 




More information about the cvs mailing list