Changeset d1b93e0


Ignore:
Timestamp:
Nov 8, 2013 2:39:43 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4e680479, d2f0c25
Parents:
4382def
Message:

DeliveryInstructions?:

  • Comment out unused encryption fields to save space
  • New static immutable LOCAL instruction to reduce object churn
Location:
router/java/src/net/i2p
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/i2np/DeliveryInstructions.java

    r4382def rd1b93e0  
    3434public class DeliveryInstructions extends DataStructureImpl {
    3535    //private final static Log _log = new Log(DeliveryInstructions.class);
    36     private boolean _encrypted;
    37     private SessionKey _encryptionKey;
     36    //private boolean _encrypted;
     37    //private SessionKey _encryptionKey;
    3838    private int _deliveryMode;
    3939    public final static int DELIVERY_MODE_LOCAL = 0;
     
    5757    private final static long FLAG_DELAY = 16;
    5858   
     59    /**
     60     *  Immutable local instructions, no options
     61     *
     62     *  @since 0.9.9
     63     */
     64    public static final DeliveryInstructions LOCAL = new LocalInstructions();
     65
    5966    public DeliveryInstructions() {
    6067        _deliveryMode = -1;
     
    6572     * @deprecated unused
    6673     */
    67     public boolean getEncrypted() { return _encrypted; }
     74    public boolean getEncrypted() { return /* _encrypted */ false; }
    6875   
    6976    /**
     
    7178     * @deprecated unused
    7279     */
    73     public void setEncrypted(boolean encrypted) { _encrypted = encrypted; }
     80    public void setEncrypted(boolean encrypted) { /* _encrypted = encrypted; */ }
    7481
    7582    /**
     
    7784     * @deprecated unused
    7885     */
    79     public SessionKey getEncryptionKey() { return _encryptionKey; }
     86    public SessionKey getEncryptionKey() { return /* _encryptionKey */ null; }
    8087
    8188    /**
     
    8390     * @deprecated unused
    8491     */
    85     public void setEncryptionKey(SessionKey key) { _encryptionKey = key; }
     92    public void setEncryptionKey(SessionKey key) { /* _encryptionKey = key; */ }
    8693
    8794    /** default -1 */
     
    122129   
    123130    /**
    124      * default 0, unusedx
     131     * default 0, unused
    125132     * @deprecated unused
    126133     */
     
    253260     */
    254261/****
    255     private boolean flagEncrypted(long flags) {
     262    private static boolean flagEncrypted(long flags) {
    256263        return (0 != (flags & FLAG_ENCRYPTED));
    257264    }
     
    259266   
    260267    /** high bits */
    261     private int flagMode(long flags) {
     268    private static int flagMode(long flags) {
    262269        long v = flags & FLAG_MODE;
    263270        v >>>= 5;
     
    266273   
    267274    /**  unused */
    268     private boolean flagDelay(long flags) {
     275    private static boolean flagDelay(long flags) {
    269276        return (0 != (flags & FLAG_DELAY));
    270277    }
     
    493500        return buf.toString();
    494501    }
     502
     503    /**
     504     *  An immutable local delivery instructions with no options
     505     *  for efficiency.
     506     *
     507     *  @since 0.9.9
     508     */
     509    private static final class LocalInstructions extends DeliveryInstructions {
     510        //private static final byte flag = DELIVERY_MODE_LOCAL << 5;  // 0
     511
     512        @Override
     513        public void setEncrypted(boolean encrypted) {
     514            throw new RuntimeException("immutable");
     515        }
     516
     517        @Override
     518        public void setEncryptionKey(SessionKey key) {
     519            throw new RuntimeException("immutable");
     520        }
     521
     522        @Override
     523        public int getDeliveryMode() { return DELIVERY_MODE_LOCAL; }
     524
     525        @Override
     526        public void setDeliveryMode(int mode) {
     527            throw new RuntimeException("immutable");
     528        }
     529
     530        @Override
     531        public void setDestination(Hash dest) {
     532            throw new RuntimeException("immutable");
     533        }
     534
     535        @Override
     536        public void setRouter(Hash router) {
     537            throw new RuntimeException("immutable");
     538        }
     539
     540        @Override
     541        public void setTunnelId(TunnelId id) {
     542            throw new RuntimeException("immutable");
     543        }
     544
     545        @Override
     546        public void setDelayRequested(boolean req) {
     547            throw new RuntimeException("immutable");
     548        }
     549
     550        @Override
     551        public void setDelaySeconds(long seconds) {
     552            throw new RuntimeException("immutable");
     553        }
     554
     555        @Override
     556        public void readBytes(InputStream in) throws DataFormatException, IOException {
     557            throw new RuntimeException("immutable");
     558        }
     559
     560        @Override
     561        public int readBytes(byte data[], int offset) throws DataFormatException {
     562            throw new RuntimeException("immutable");
     563        }
     564
     565        @Override
     566        public void writeBytes(OutputStream out) throws DataFormatException, IOException {
     567            out.write((byte) 0);
     568        }
     569
     570        @Override
     571        public int writeBytes(byte target[], int offset) {
     572            target[offset] = 0;
     573            return 1;
     574        }
     575
     576        @Override
     577        public int getSize() {
     578            return 1;
     579        }
     580
     581        @Override
     582        public String toString() {
     583            return "[DeliveryInstructions: " +
     584                   "\n\tDelivery mode: " +
     585                   "local]";
     586        }
     587    }
    495588}
  • router/java/src/net/i2p/router/RouterVersion.java

    r4382def rd1b93e0  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 22;
     21    public final static long BUILD = 23;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/message/OutboundClientMessageJobHelper.java

    r4382def rd1b93e0  
    123123        config.addClove(dataClove);
    124124
    125         DeliveryInstructions instructions = new DeliveryInstructions();
    126         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    127         // defaults
    128         //instructions.setDelayRequested(false);
    129         //instructions.setDelaySeconds(0);
    130         //instructions.setEncrypted(false);
    131         //instructions.setEncryptionKey(null);
    132         //instructions.setRouter(null);
    133         //instructions.setTunnelId(null);
    134        
    135125        config.setCertificate(Certificate.NULL_CERT);
    136         config.setDeliveryInstructions(instructions);
     126        config.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    137127        config.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
    138128        config.setExpiration(expiration); // +2*Router.CLOCK_FUDGE_FACTOR);
     
    234224    static PayloadGarlicConfig buildLeaseSetClove(RouterContext ctx, long expiration, LeaseSet replyLeaseSet) {
    235225        PayloadGarlicConfig clove = new PayloadGarlicConfig();
    236        
    237         DeliveryInstructions instructions = new DeliveryInstructions();
    238         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    239         // defaults
    240         //instructions.setDelayRequested(false);
    241         //instructions.setDelaySeconds(0);
    242         //instructions.setEncrypted(false);
    243        
    244226        clove.setCertificate(Certificate.NULL_CERT);
    245         clove.setDeliveryInstructions(instructions);
     227        clove.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    246228        clove.setExpiration(expiration);
    247229        clove.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
  • router/java/src/net/i2p/router/networkdb/kademlia/MessageWrapper.java

    r4382def rd1b93e0  
    4444     */
    4545    static WrappedMessage wrap(RouterContext ctx, I2NPMessage m, Hash from, RouterInfo to) {
    46         DeliveryInstructions instructions = new DeliveryInstructions();
    47         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    48 
    4946        PayloadGarlicConfig payload = new PayloadGarlicConfig();
    5047        payload.setCertificate(Certificate.NULL_CERT);
     
    5249        payload.setPayload(m);
    5350        payload.setRecipient(to);
    54         payload.setDeliveryInstructions(instructions);
     51        payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    5552        payload.setExpiration(m.getMessageExpiration());
    5653
     
    128125     */
    129126    static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, RouterInfo to) {
    130         DeliveryInstructions instructions = new DeliveryInstructions();
    131         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    132 
    133127        PayloadGarlicConfig payload = new PayloadGarlicConfig();
    134128        payload.setCertificate(Certificate.NULL_CERT);
     
    136130        payload.setPayload(m);
    137131        payload.setRecipient(to);
    138         payload.setDeliveryInstructions(instructions);
     132        payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    139133        payload.setExpiration(m.getMessageExpiration());
    140134
     
    216210     */
    217211    public static GarlicMessage wrap(RouterContext ctx, I2NPMessage m, SessionKey encryptKey, SessionTag encryptTag) {
    218         DeliveryInstructions instructions = new DeliveryInstructions();
    219         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    220 
    221212        PayloadGarlicConfig payload = new PayloadGarlicConfig();
    222213        payload.setCertificate(Certificate.NULL_CERT);
    223214        payload.setId(ctx.random().nextLong(I2NPMessage.MAX_ID_VALUE));
    224215        payload.setPayload(m);
    225         payload.setDeliveryInstructions(instructions);
     216        payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    226217        payload.setExpiration(m.getMessageExpiration());
    227218
  • router/java/src/net/i2p/router/tunnel/pool/TestJob.java

    r4382def rd1b93e0  
    116116        // remembering that key+tag so that we can decrypt it later.  this means we can do the
    117117        // garlic encryption without any ElGamal (yay)
    118         DeliveryInstructions instructions = new DeliveryInstructions();
    119         instructions.setDeliveryMode(DeliveryInstructions.DELIVERY_MODE_LOCAL);
    120 
    121118        PayloadGarlicConfig payload = new PayloadGarlicConfig();
    122119        payload.setCertificate(Certificate.NULL_CERT);
     
    124121        payload.setPayload(m);
    125122        payload.setRecipient(getContext().router().getRouterInfo());
    126         payload.setDeliveryInstructions(instructions);
     123        payload.setDeliveryInstructions(DeliveryInstructions.LOCAL);
    127124        payload.setExpiration(m.getMessageExpiration());
    128125
Note: See TracChangeset for help on using the changeset viewer.