* Data Structures: More caching and cleanups

This commit is contained in:
zzz
2010-12-31 13:21:05 +00:00
parent e0f77731c5
commit ed8197f6d2
11 changed files with 66 additions and 21 deletions

View File

@@ -305,7 +305,7 @@ public class Blocklist {
if (end1 - start1 == 44 && buf.substring(start1).indexOf(".") < 0) {
byte b[] = Base64.decode(buf.substring(start1));
if (b != null)
return new Entry(comment, new Hash(b), null, null);
return new Entry(comment, Hash.create(b), null, null);
}
index = buf.indexOf("-", start1);
if (index >= 0) {

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 5;
public final static long BUILD = 6;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -18,6 +18,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentHashMap;
import net.i2p.data.Base64;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataStructure;
import net.i2p.data.Hash;
@@ -481,8 +482,12 @@ class PersistentDataStore extends TransientDataStore {
try {
String key = filename.substring(prefix.length());
key = key.substring(0, key.length() - suffix.length());
Hash h = new Hash();
h.fromBase64(key);
//Hash h = new Hash();
//h.fromBase64(key);
byte[] b = Base64.decode(key);
if (b == null)
return null;
Hash h = Hash.create(b);
return h;
} catch (Exception e) {
// static

View File

@@ -937,11 +937,9 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
RouterAddress addr = _externalAddress;
UDPAddress ua = new UDPAddress(addr);
int valid = 0;
Hash peerHash = new Hash();
for (int i = 0; i < ua.getIntroducerCount(); i++) {
// warning: this is only valid as long as we use the ident hash as their key.
peerHash.setData(ua.getIntroducerKey(i));
PeerState peer = getPeerState(peerHash);
PeerState peer = getPeerState(Hash.create(ua.getIntroducerKey(i)));
if (peer != null)
valid++;
}