All Implemented Interfaces:
I2NPMessage

public class DeliveryStatusMessageextends FastI2NPMessageImpl
Defines the message sent back in reply to a message when requested, containing the private ack id.
  • Field Details

    • MESSAGE_TYPE

      public static final int MESSAGE_TYPE
      I2NP message type number identifying a delivery status reply.
      See Also:
    • _id

      private long _id
      Message ID being reported on.
    • _arrival

      private long _arrival
      Time the message arrived at its destination.
    • MAX_MSG_ID

      private static final long MAX_MSG_ID
      4 bytes unsigned.
      See Also:
  • Constructor Details

    • DeliveryStatusMessage

      public DeliveryStatusMessage(I2PAppContext context)
      Create a delivery status message.
      Parameters:
      context - the app context supplying the log, the clock that stamps the expiry, and the random source that mints message ids
  • Method Details

    • getMessageId

      public long getMessageId()
      The message id being acknowledged.
      Returns:
      the message id
    • setMessageId

      public void setMessageId(long id)
      Message ID for this delivery status.
      Parameters:
      id - 0 to (2**32) - 1
      Throws:
      IllegalStateException - if id previously set, to protect saved checksum
      IllegalArgumentException - if id is out of range
    • getArrival

      public long getArrival()
      Misnamed, as it is generally (always?) set by the creator to the current time, in some future usage it could be set on arrival.
      Returns:
      the arrival time
    • setArrival

      public void setArrival(long arrival)
      Misnamed, as it is generally (always?) set by the creator to the current time, in some future usage it could be set on arrival.
      Parameters:
      arrival - the arrival time
    • readMessage

      public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException
      Populate the message fields from the byte array, starting at the given offset.
      Parameters:
      data - data to read from
      offset - where to start in the data array
      dataSize - how long into the data to read
      type - I2NP message type
      Throws:
      I2NPMessageException - if the stream doesn't contain a valid message that this class can read.
    • calculateWrittenLength

      protected int calculateWrittenLength()
      Calculate the message body's length (not including the header and footer).
      Specified by:
      calculateWrittenLength in class I2NPMessageImpl
      Returns:
      the number of bytes the body will occupy once serialized
    • writeMessageBody

      protected int writeMessageBody(byte[] out, int curIndex) throws I2NPMessageException
      Write the message body to the output array, starting at the given index.
      Specified by:
      writeMessageBody in class I2NPMessageImpl
      Parameters:
      out - the buffer to serialize the body into
      curIndex - the offset into out at which to begin writing; leave room for the signature where the header format calls for one
      Returns:
      the index into the array after the last byte written (NOT the length)
      Throws:
      I2NPMessageException - if the body cannot be serialized into out, because it is too small or a field is unserializable
    • getType

      public int getType()
      The I2NP message type of a delivery status message.
      Returns:
      the constant MESSAGE_TYPE (10), which is the wire type identifying this message as a delivery status message
    • hashCode

      public int hashCode()
      Hash code combining the message id and arrival time.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object object)
      Compare the message id and arrival time for equality.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      String form for debugging, showing the message id and time since arrival.
      Overrides:
      toString in class Object