Author: j16sdiz
Date: 2008-09-04 15:32:25 +0000 (Thu, 04 Sep 2008)
New Revision: 22415
Removed:
trunk/freenet/src/freenet/support/ImmutableByteArrayWrapper.java
Modified:
trunk/freenet/src/freenet/node/Node.java
Log:
solve issue #2333: replace ImmutableByteArrayWrapper with ByteArrayWrapper
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2008-09-04 15:32:01 UTC (rev
22414)
+++ trunk/freenet/src/freenet/node/Node.java 2008-09-04 15:32:25 UTC (rev
22415)
@@ -97,6 +97,7 @@
import freenet.store.RAMFreenetStore;
import freenet.store.SSKStore;
import freenet.store.saltedhash.SaltedHashFreenetStore;
+import freenet.support.ByteArrayWrapper;
import freenet.support.DoubleTokenBucket;
import freenet.support.Executor;
import freenet.support.Fields;
@@ -104,7 +105,6 @@
import freenet.support.HTMLEncoder;
import freenet.support.HTMLNode;
import freenet.support.HexUtil;
-import freenet.support.ImmutableByteArrayWrapper;
import freenet.support.LRUHashtable;
import freenet.support.LRUQueue;
import freenet.support.Logger;
@@ -414,7 +414,7 @@
final NodeDispatcher dispatcher;
public final UptimeEstimator uptime;
static final int MAX_MEMORY_CACHED_PUBKEYS = 1000;
- final LRUHashtable<ImmutableByteArrayWrapper, DSAPublicKey>
cachedPubKeys;
+ final LRUHashtable<ByteArrayWrapper, DSAPublicKey> cachedPubKeys;
final boolean testnetEnabled;
final TestnetHandler testnetHandler;
public final DoubleTokenBucket outputThrottle;
@@ -730,7 +730,7 @@
nodeNameUserAlert = new MeaningfulNodeNameUserAlert(this);
recentlyCompletedIDs = new LRUQueue();
this.config = config;
- cachedPubKeys = new LRUHashtable<ImmutableByteArrayWrapper,
DSAPublicKey>();
+ cachedPubKeys = new LRUHashtable<ByteArrayWrapper,
DSAPublicKey>();
lm = new LocationManager(random, this);
try {
@@ -2829,7 +2829,7 @@
* @see freenet.node.GetPubkey#getKey(byte[])
*/
public DSAPublicKey getKey(byte[] hash) {
- ImmutableByteArrayWrapper w = new
ImmutableByteArrayWrapper(hash);
+ ByteArrayWrapper w = new ByteArrayWrapper(hash);
if(logMINOR) Logger.minor(this, "Getting pubkey:
"+HexUtil.bytesToHex(hash));
if(USE_RAM_PUBKEYS_CACHE) {
synchronized(cachedPubKeys) {
@@ -2863,7 +2863,7 @@
*/
public void cacheKey(byte[] hash, DSAPublicKey key, boolean deep) {
if(logMINOR) Logger.minor(this, "Cache key:
"+HexUtil.bytesToHex(hash)+" : "+key);
- ImmutableByteArrayWrapper w = new
ImmutableByteArrayWrapper(hash);
+ ByteArrayWrapper w = new ByteArrayWrapper(hash);
synchronized(cachedPubKeys) {
DSAPublicKey key2 = cachedPubKeys.get(w);
if((key2 != null) && !key2.equals(key)) {
Deleted: trunk/freenet/src/freenet/support/ImmutableByteArrayWrapper.java
===================================================================
--- trunk/freenet/src/freenet/support/ImmutableByteArrayWrapper.java
2008-09-04 15:32:01 UTC (rev 22414)
+++ trunk/freenet/src/freenet/support/ImmutableByteArrayWrapper.java
2008-09-04 15:32:25 UTC (rev 22415)
@@ -1,30 +0,0 @@
-/**
- *
- */
-package freenet.support;
-
-import java.util.Arrays;
-
-public class ImmutableByteArrayWrapper {
- final byte[] data;
- final int hashCode;
-
- public ImmutableByteArrayWrapper(byte[] data) {
- this.data = data;
- hashCode = Fields.hashCode(data);
- }
-
- public boolean equals(Object o) {
- if(o instanceof ImmutableByteArrayWrapper) {
- ImmutableByteArrayWrapper w =
(ImmutableByteArrayWrapper) o;
- if((w.hashCode == hashCode) &&
- Arrays.equals(data, w.data))
- return true;
- }
- return false;
- }
-
- public int hashCode() {
- return hashCode;
- }
-}
\ No newline at end of file