Class MessageValidator
A helper class for an IMessageCodec<T> to validate a decoded Message.
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.Net.dll
Syntax
public class MessageValidator : object
Properties
| Improve this Doc View SourceApv
The local AppProtocolVersion used for Encode(Message, PrivateKey, AppProtocolVersion, BoundPeer, DateTimeOffset) and Decode(T, Boolean) methods.
In particular, this is used in the following cases:
- When encoding, this value is attached to the encoded output.
- When decoding, the encoded message's AppProtocolVersion must match this value.
Declaration
public AppProtocolVersion Apv { get; }
Property Value
Type | Description |
---|---|
AppProtocolVersion |
DifferentApvEncountered
A callback method that gets invoked when a an AppProtocolVersion by a trusted signer that is different from Apv is encountered.
Declaration
public DifferentAppProtocolVersionEncountered DifferentApvEncountered { get; }
Property Value
Type | Description |
---|---|
DifferentAppProtocolVersionEncountered |
Remarks
If null
, no action is taken.
MessageTimestampBuffer
The
Whether a decoded Message is valid or not depends on this value:
Declaration
public TimeSpan? MessageTimestampBuffer { get; }
Property Value
Type | Description |
---|---|
Nullable<TimeSpan> |
TrustedApvSigners
An
Whether to trust an unknown AppProtocolVersion, i.e. an AppProtocolVersion that is different from Apv, depends on this value:
-
If
null
, the AppProtocolVersion in question is trusted regardless of its signer. -
If not
null
, an AppProtocolVersion is trusted if it is signed by one of the signers in the set. In particular, if the set is empty, no AppProtocolVersion is trusted.
Declaration
public IImmutableSet<PublicKey>? TrustedApvSigners { get; }
Property Value
Type | Description |
---|---|
Nullable<IImmutableSet<PublicKey>> |
Methods
| Improve this Doc View SourceValidateAppProtocolVersion(Message)
Validates an AppProtocolVersion against Apv. Any AppProtocolVersion that is different from Apv is considered invalid and an DifferentAppProtocolVersionException will be thrown.
Declaration
public void ValidateAppProtocolVersion(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message | The Message to validate. |
Remarks
If Version of message
is not valid but
is signed by a trusted signer, then DifferentApvEncountered is called.
Exceptions
Type | Condition |
---|---|
DifferentAppProtocolVersionException | Thrown when
local version does not match with given |
See Also
| Improve this Doc View SourceValidateTimestamp(Message)
Validates a
Declaration
public void ValidateTimestamp(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message | The Message to validate. |
Exceptions
Type | Condition |
---|---|
InvalidMessageTimestampException | Thrown when the timestamp of
|