Changeset f5f411b6


Ignore:
Timestamp:
Oct 21, 2016 6:08:31 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
71f7c71
Parents:
d367149
Message:

Data: Cache serialized leasesets on floodfills

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/LeaseSet.java

    rd367149 rf5f411b6  
    7373    private boolean _decrypted;
    7474    private boolean _checked;
     75    // cached byte version
     76    private volatile byte _byteified[];
    7577
    7678    /**
     
    9395
    9496    public LeaseSet() {
    95         _leases = new ArrayList<Lease>(OLD_MAX_LEASES);
     97        _leases = new ArrayList<Lease>(2);
    9698        _firstExpiration = Long.MAX_VALUE;
    9799    }
     
    287289
    288290    protected byte[] getBytes() {
     291        if (_byteified != null) return _byteified;
    289292        if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null))
    290293            return null;
     
    299302            _encryptionKey.writeBytes(out);
    300303            _signingKey.writeBytes(out);
    301             DataHelper.writeLong(out, 1, _leases.size());
    302             //DataHelper.writeLong(out, 4, _version);
     304            out.write((byte) _leases.size());
    303305            for (Lease lease : _leases)
    304306                lease.writeBytes(out);
     
    309311        }
    310312        byte rv[] = out.toByteArray();
     313        // if we are floodfill and this was published to us
     314        if (_receivedAsPublished)
     315            _byteified = rv;
    311316        return rv;
    312317    }
     
    349354        _encryptionKey.writeBytes(out);
    350355        _signingKey.writeBytes(out);
    351         DataHelper.writeLong(out, 1, _leases.size());
    352         //DataHelper.writeLong(out, 4, _version);
     356        out.write((byte) _leases.size());
    353357        for (Lease lease : _leases)
    354358            lease.writeBytes(out);
Note: See TracChangeset for help on using the changeset viewer.