Class MessageValidator
A helper class for an IMessageCodec<T> to validate a decoded Message.
Inherited Members
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.Net.dll
Syntax
public class MessageValidator
Properties
| Improve this Doc View SourceApv
The local AppProtocolVersion used for Encode(MessageContent, PrivateKey, AppProtocolVersion, BoundPeer, DateTimeOffset, Byte[]) 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 TimeSpan to use as a buffer when decoding Messages.
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 IImmutableSet<T> of Addresses to trust as a signer when a different AppProtocolVersion is encountered.
Whether to trust an unknown AppProtocolVersion, i.e. an AppProtocolVersion that is different from Apv. 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 |
---|---|
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 |
---|---|
NullReferenceException | Thrown when Remote is
null for |
DifferentAppProtocolVersionException | Thrown when
local version does not match with given |
See Also
| Improve this Doc View SourceValidateTimestamp(Message)
Validates a DateTimeOffset timestamp against current timestamp.
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
|