java.lang.Object
net.i2p.router.MessageValidator
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
ConstructorsConstructorDescriptionMessageValidator(RouterContext context) Registers the duplicate and expiry rate stats the validator reports into.Method Summary
All MethodsModifier and TypeMethodDescription(package private) voidshutdown()Stop the message validator and clean up resources.voidstartup()Start the message validator, initializing the duplicate detection filter.validateMessage(long expiration) Only check the expiration for the message.validateMessage(long messageId, long expiration) Determine if this message should be accepted as valid (not expired, not a duplicate).
Constructor Details
MessageValidator
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
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 duplicateexpiration- the message expiry date in milliseconds since the epoch- Returns:
- reason why the message is invalid (or null if the message is valid)
validateMessage
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.