java.lang.Object
net.i2p.router.tunnel.PendingGatewayMessage
All Implemented Interfaces:
CDQEntry
Direct Known Subclasses:
OutboundGatewayMessage

class PendingGatewayMessageextends Object implements CDQEntry
Stores all the state for an unsent or partially-sent message.
  • Field Details

    • _toRouter

      protected final Hash _toRouter
      The destination router.
    • _toTunnel

      protected final TunnelId _toTunnel
      The destination tunnel.
    • _messageId

      protected final long _messageId
      The message ID.
    • _expiration

      protected final long _expiration
      The message expiration.
    • _remaining

      protected final byte[] _remaining
      Raw unfragmented message data.
    • _offset

      protected volatile int _offset
      Index into the data to be sent.
    • _fragmentNumber

      protected int _fragmentNumber
      Which fragment we are working on.
    • _created

      protected final long _created
      When this message was created.
    • _messageIds

      private List<Long> _messageIds
      IDs of TunnelDataMessages this message was fragmented into.
    • _enqueueTime

      private long _enqueueTime
      Time enqueued in CDQ.
  • Constructor Details

    • PendingGatewayMessage

      public PendingGatewayMessage(I2NPMessage message, Hash toRouter, TunnelId toTunnel)
      Stores the message data, destination, and expiration for a pending send.
      Parameters:
      message - the I2NP message to deliver, serialized and tracked until sent
      toRouter - the hash of the next-hop router the message is addressed to
      toTunnel - the tunnel the message will be injected into at that router
  • Method Details

    • getToRouter

      public Hash getToRouter()
      The destination router.
      Returns:
      may be null
    • getToTunnel

      public TunnelId getToTunnel()
      The destination tunnel.
      Returns:
      may be null
    • getMessageId

      public long getMessageId()
      Message ID.
      Returns:
      the message ID
    • getExpiration

      public long getExpiration()
      Message expiration time.
      Returns:
      the message expiration
    • getData

      public byte[] getData()
      The raw unfragmented message to send.
      Returns:
      the message data
    • getOffset

      public int getOffset()
      The index into the data to be sent.
      Returns:
      the index of the next byte to send, 0 when the whole message is unsent
    • setOffset

      public void setOffset(int offset)
      Move the offset.
      Parameters:
      offset - the new offset value
    • getLifetime

      public long getLifetime()
      Lifetime in milliseconds.
      Returns:
      the lifetime in milliseconds
    • getFragmentNumber

      public int getFragmentNumber()
      Which fragment are we working on (0 for the first fragment).
      Returns:
      the fragment number
    • incrementFragmentNumber

      public void incrementFragmentNumber()
      Fragment sent, so move on to the next one.
    • addMessageId

      public void addMessageId(long id)
      Add an ID to the list of the TunnelDataMssages this message was fragmented into. Unused except in notePreprocessing() calls for debugging.
      Parameters:
      id - the message ID to add
    • getMessageIds

      public List<Long> getMessageIds()
      The IDs of the TunnelDataMssages this message was fragmented into. Unused except in notePreprocessing() calls for debugging.
      Returns:
      non-null list of message IDs
    • setEnqueueTime

      public void setEnqueueTime(long now)
      For CDQ.
      Specified by:
      setEnqueueTime in interface CDQEntry
      Parameters:
      now - the enqueue timestamp
    • getEnqueueTime

      public long getEnqueueTime()
      For CDQ.
      Specified by:
      getEnqueueTime in interface CDQEntry
      Returns:
      the enqueue time
    • drop

      public void drop()
      For CDQ.
      Specified by:
      drop in interface CDQEntry
    • toString

      public String toString()
      Debug description of this pending message and its progress.
      Overrides:
      toString in class Object