net.i2p.router

## Class MessageValidator

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

-     public class MessageValidator
      extends 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 Summary

    Constructors
    Constructor and Description
    `MessageValidator(RouterContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `shutdown()` Stop the message validator and clean up resources.
    `void` | `startup()` Start the message validator, initializing the duplicate detection filter.
    `String` | `validateMessage(long expiration)` Only check the expiration for the message
    `String` | `validateMessage(long messageId, long expiration)` Determine if this message should be accepted as valid (not expired, not a duplicate)

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MessageValidator

          public MessageValidator(RouterContext context)

  - ### Method Detail

    - #### shutdown

          void shutdown()

      Stop the message validator and clean up resources.

    - #### startup

          public void startup()

      Start the message validator, initializing the duplicate detection filter.

    - #### validateMessage

          public String validateMessage(long expiration)

      Only check the expiration for the message

    - #### validateMessage

          public String validateMessage(long messageId,
                                        long expiration)

      Determine if this message should be accepted as valid (not expired, not a duplicate)
      Returns:
        reason why the message is invalid (or null if the message is valid)