Class FastI2NPMessageImpl

    • Field Detail

      • _checksum

        protected byte _checksum
      • _hasChecksum

        protected boolean _hasChecksum
    • Constructor Detail

      • FastI2NPMessageImpl

        public FastI2NPMessageImpl​(I2PAppContext context)
    • Method Detail

      • readBytes

        public int readBytes​(byte[] data,
                             int type,
                             int offset,
                             int maxLen)
                      throws I2NPMessageException
        Ignore, but save, the checksum, to be used later if necessary.
        Specified by:
        readBytes in interface I2NPMessage
        Overrides:
        readBytes in class I2NPMessageImpl
        Parameters:
        maxLen - read no more than this many bytes from data starting at offset, even if it is longer This includes the type byte only if type < 0
        data - the data, may or may not include the type
        type - I2NP message type. If less than zero, read the type from data
        offset - where to start starting at type if type is < 0 (16 byte header) starting at ID if type is >= 0 (15 byte header)
        Returns:
        size of the message read (including headers)
        Throws:
        IllegalStateException - if called twice, to protect saved checksum
        I2NPMessageException - if there is no valid message
      • toByteArray

        public int toByteArray​(byte[] buffer)
        If available, use the previously-computed or previously-read checksum for speed
        Specified by:
        toByteArray in interface I2NPMessage
        Overrides:
        toByteArray in class I2NPMessageImpl
        Returns:
        the length written
      • toByteArrayWithSavedChecksum

        protected int toByteArrayWithSavedChecksum​(byte[] buffer)
        Use a previously-computed checksum for speed