[freenet-cvs] r16879 - trunk/freenet/src/freenet/store

toad at freenetproject.org toad at freenetproject.org
Fri Jan 4 15:10:23 UTC 2008


Author: toad
Date: 2008-01-04 15:10:22 +0000 (Fri, 04 Jan 2008)
New Revision: 16879

Modified:
   trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
Log:
Put in assertions to check the storeType against the access made.

Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java	2008-01-04 15:07:57 UTC (rev 16878)
+++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java	2008-01-04 15:10:22 UTC (rev 16879)
@@ -1148,6 +1148,7 @@
 	* @return null if there is no such block stored, otherwise the block.
 	*/
 	public CHKBlock fetch(NodeCHK chk, boolean dontPromote) throws IOException {
+		assert(storeType == TYPE_CHK);
 		synchronized(this) {
 			if(closed)
 				return null;
@@ -1284,6 +1285,7 @@
 	* @return null if there is no such block stored, otherwise the block.
 	*/
 	public SSKBlock fetch(NodeSSK chk, boolean dontPromote) throws IOException {
+		assert(storeType == TYPE_SSK);
 		synchronized(this) {
 			if(closed)
 				return null;
@@ -1407,6 +1409,7 @@
 	* @return null if there is no such block stored, otherwise the block.
 	*/
 	public DSAPublicKey fetchPubKey(byte[] hash, DSAPublicKey replacement, boolean dontPromote) throws IOException {
+		assert(storeType == TYPE_PUBKEY);
 		synchronized(this) {
 			if(closed)
 				return null;
@@ -1565,6 +1568,7 @@
 	}
 
 	public void put(CHKBlock b) throws IOException {
+		assert(storeType == TYPE_CHK);
 		NodeCHK chk = (NodeCHK) b.getKey();
 		CHKBlock oldBlock = fetch(chk, false);
 		if(oldBlock != null)
@@ -1573,6 +1577,7 @@
 	}
 	
 	public void put(SSKBlock b, boolean overwrite) throws IOException, KeyCollisionException {
+		assert(storeType == TYPE_SSK);
 		NodeSSK ssk = (NodeSSK) b.getKey();
 		SSKBlock oldBlock = fetch(ssk, false);
 		if(oldBlock != null) {
@@ -1589,6 +1594,7 @@
 	}
 	
 	private boolean overwrite(SSKBlock b) throws IOException {
+		assert(storeType == TYPE_SSK);
 		synchronized(this) {
 			if(closed)
 				return false;
@@ -1845,6 +1851,7 @@
 	* Store a pubkey.
 	*/
 	public void put(byte[] hash, DSAPublicKey key) throws IOException {
+		assert(storeType == TYPE_PUBKEY);
 		innerPut(hash, key);
 	}
 




More information about the cvs mailing list