java.lang.Object
net.i2p.router.MessageValidator

public class MessageValidatorextends Object
Singleton to manage the logic (and historical data) to determine whether a message is valid or not (meaning it isn't expired and hasn't already been received). We'll need a revamp once we start dealing with long message expirations (since it might involve keeping a significant number of entries in memory), but that probably won't be necessary until I2P 3.0.
  • Constructor Details

    • MessageValidator

      public MessageValidator(RouterContext context)
      Registers the duplicate and expiry rate stats the validator reports into.
      Parameters:
      context - the router context supplying the log, clock and stats used to validate messages
  • Method Details

    • validateMessage

      public String validateMessage(long messageId, long expiration)
      Determine if this message should be accepted as valid (not expired, not a duplicate).
      Parameters:
      messageId - the message ID to remember as received, so a second copy with the same ID is rejected as a duplicate
      expiration - the message expiry date in milliseconds since the epoch
      Returns:
      reason why the message is invalid (or null if the message is valid)
    • validateMessage

      public String validateMessage(long expiration)
      Only check the expiration for the message.
      Parameters:
      expiration - the message expiry date in milliseconds since the epoch, compared against the current time with the clock fudge factor
      Returns:
      reason why the message is invalid (or null if the message is valid)
    • startup

      public void startup()
      Start the message validator, initializing the duplicate detection filter.
    • shutdown

      void shutdown()
      Stop the message validator and clean up resources.