Show / Hide Table of Contents

Class MessageValidator

A helper class for an IMessageCodec<T> to validate a decoded Message.

Inheritance
Object
MessageValidator
Namespace: Libplanet.Net.Messages
Assembly: Libplanet.Net.dll
Syntax
public class MessageValidator : object

Properties

| Improve this Doc View Source

Apv

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
| Improve this Doc View Source

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.

| Improve this Doc View Source

MessageTimestampBuffer

The to use as a buffer when decoding Messages.

Whether a decoded Message is valid or not depends on this value:

  • If null, there is no restriction on Timestamp for received Messages.
  • If not null, the absolute difference between the timestamp of a received Message and current time should be less than this value.

Declaration
public TimeSpan? MessageTimestampBuffer { get; }
Property Value
Type Description
Nullable<TimeSpan>
| Improve this Doc View Source

TrustedApvSigners

An 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, 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 Source

ValidateAppProtocolVersion(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 message's Version.

See Also
Apv
TrustedApvSigners
DifferentApvEncountered
| Improve this Doc View Source

ValidateTimestamp(Message)

Validates a 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 message is invalid.

See Also
MessageTimestampBuffer
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2022 Planetarium