Changeset ed8197f


Ignore:
Timestamp:
Dec 31, 2010 1:21:05 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ca5ed9d, ffcff54
Parents:
e0f7773
Message:
  • Data Structures: More caching and cleanups
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/client/naming/LookupDest.java

    re0f7773 red8197f  
    5555    /** @param h 32 byte hash */
    5656    static Destination lookupHash(I2PAppContext ctx, byte[] h) {
    57         Hash key = new Hash(h);
     57        Hash key = Hash.create(h);
    5858        Destination rv = null;
    5959        try {
  • core/java/src/net/i2p/data/Certificate.java

    re0f7773 red8197f  
    4343    /** Contains multiple certs */
    4444    public final static int CERTIFICATE_TYPE_MULTIPLE = 4;
     45
     46    /**
     47     * Pull from cache or return new
     48     * @throws AIOOBE if not enough bytes
     49     * @since 0.8.3
     50     */
     51    public static Certificate create(byte[] data, int off) {
     52        int type = data[off] & 0xff;
     53        int length = (int) DataHelper.fromLong(data, off + 1, 2);
     54        if (type == 0 && length == 0)
     55            return NULL_CERT;
     56        // from here down roughly the same as readBytes() below
     57        if (length == 0)
     58            return new Certificate(type, null);
     59        byte[] payload = new byte[length];
     60        System.arraycopy(data, off = 3, payload, 0, length);
     61        return new Certificate(type, payload);
     62    }
    4563
    4664    /**
  • core/java/src/net/i2p/data/Destination.java

    re0f7773 red8197f  
    5050        int cur = offset;
    5151       
    52         _publicKey = new PublicKey();
    53         byte buf[] = new byte[PublicKey.KEYSIZE_BYTES];
    54         System.arraycopy(source, cur, buf, 0, PublicKey.KEYSIZE_BYTES);
    55         _publicKey.setData(buf);
     52        _publicKey = PublicKey.create(source, cur);
    5653        cur += PublicKey.KEYSIZE_BYTES;
    5754       
    58         _signingKey = new SigningPublicKey();
    59         buf = new byte[SigningPublicKey.KEYSIZE_BYTES];
    60         System.arraycopy(source, cur, buf, 0, SigningPublicKey.KEYSIZE_BYTES);
    61         _signingKey.setData(buf);
     55        _signingKey = SigningPublicKey.create(source, cur);
    6256        cur += SigningPublicKey.KEYSIZE_BYTES;
    6357       
    64         _certificate = new Certificate();
    65         cur += _certificate.readBytes(source, cur);
     58        _certificate = Certificate.create(source, cur);
     59        cur += _certificate.size();
    6660       
    6761        return cur - offset;
  • core/java/src/net/i2p/data/PublicKey.java

    re0f7773 red8197f  
    2525
    2626    private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
     27
     28    /**
     29     * Pull from cache or return new
     30     * @throws AIOOBE if not enough bytes
     31     * @since 0.8.3
     32     */
     33    public static PublicKey create(byte[] data, int off) {
     34        return _cache.get(data, off);
     35    }
    2736
    2837    /**
  • core/java/src/net/i2p/data/SigningPublicKey.java

    re0f7773 red8197f  
    2929    /**
    3030     * Pull from cache or return new
     31     * @throws AIOOBE if not enough bytes
     32     * @since 0.8.3
     33     */
     34    public static SigningPublicKey create(byte[] data, int off) {
     35        return _cache.get(data, off);
     36    }
     37
     38    /**
     39     * Pull from cache or return new
    3140     * @since 0.8.3
    3241     */
  • core/java/src/net/i2p/data/i2cp/DestReplyMessage.java

    re0f7773 red8197f  
    6161            try {
    6262                if (size == Hash.HASH_LENGTH) {
    63                     Hash h = new Hash();
    64                     h.readBytes(in);
    65                     _hash = h;
     63                    _hash = Hash.create(in);
    6664                } else {
    6765                    Destination d = new Destination();
  • history.txt

    re0f7773 red8197f  
     12010-12-31 zzz
     2    * Console:
     3      - Make themes and history.txt return 403 on error,
     4        not 500, to avoid the new error page
     5      - Add logging, enable with routerconsole.log=filename
     6      - Link to full history.txt on help page
     7    * Data Structures: Caching cleanups
     8    * Datagram Dissector: Fix RuntimeException caused by reuse,
     9                          preventing iMule from connecting on UDP
     10                          (thanks devzero)
     11    * i2psnark:
     12      - Send cache directive for in-war icons
     13    * OCMOSJ: Refactor cache keys for efficiency
     14
    1152010-12-30 zzz
    216    * Data Structures:
  • router/java/src/net/i2p/router/Blocklist.java

    re0f7773 red8197f  
    306306            byte b[] = Base64.decode(buf.substring(start1));
    307307            if (b != null)
    308                 return new Entry(comment, new Hash(b), null, null);
     308                return new Entry(comment, Hash.create(b), null, null);
    309309        }
    310310        index = buf.indexOf("-", start1);
  • router/java/src/net/i2p/router/RouterVersion.java

    re0f7773 red8197f  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 5;
     21    public final static long BUILD = 6;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java

    re0f7773 red8197f  
    1919import java.util.concurrent.ConcurrentHashMap;
    2020
     21import net.i2p.data.Base64;
    2122import net.i2p.data.DataFormatException;
    2223import net.i2p.data.DataStructure;
     
    482483            String key = filename.substring(prefix.length());
    483484            key = key.substring(0, key.length() - suffix.length());
    484             Hash h = new Hash();
    485             h.fromBase64(key);
     485            //Hash h = new Hash();
     486            //h.fromBase64(key);
     487            byte[] b = Base64.decode(key);
     488            if (b == null)
     489                return null;
     490            Hash h = Hash.create(b);
    486491            return h;
    487492        } catch (Exception e) {
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    re0f7773 red8197f  
    938938            UDPAddress ua = new UDPAddress(addr);
    939939            int valid = 0;
    940             Hash peerHash = new Hash();
    941940            for (int i = 0; i < ua.getIntroducerCount(); i++) {
    942941                // warning: this is only valid as long as we use the ident hash as their key.
    943                 peerHash.setData(ua.getIntroducerKey(i));
    944                 PeerState peer = getPeerState(peerHash);
     942                PeerState peer = getPeerState(Hash.create(ua.getIntroducerKey(i)));
    945943                if (peer != null)
    946944                    valid++;
Note: See TracChangeset for help on using the changeset viewer.