Documentation ¶
Index ¶
- Variables
- func NewAnyValidator(validators ...network.MessageValidator) network.MessageValidator
- func NewNotValidator(validator network.MessageValidator) network.MessageValidator
- func NewOriginValidator(provider module.IdentifierProvider) network.MessageValidator
- func ValidateNotSender(sender flow.Identifier) network.MessageValidator
- func ValidateSender(sender flow.Identifier) network.MessageValidator
- func ValidateTarget(log zerolog.Logger, target flow.Identifier) network.MessageValidator
- type AnyValidator
- type AuthorizedSenderValidator
- type GetIdentityFunc
- type MessageValidator
- type NotValidator
- type OriginValidator
- type PubSubMessageValidator
- type SenderValidator
- type TargetValidator
Constants ¶
This section is empty.
Variables ¶
var ( ErrSenderEjected = errors.New("validation failed: sender is an ejected node") ErrIdentityUnverified = errors.New("validation failed: could not verify identity of sender") )
Functions ¶
func NewAnyValidator ¶
func NewAnyValidator(validators ...network.MessageValidator) network.MessageValidator
func NewNotValidator ¶
func NewNotValidator(validator network.MessageValidator) network.MessageValidator
func NewOriginValidator ¶
func NewOriginValidator(provider module.IdentifierProvider) network.MessageValidator
func ValidateNotSender ¶
func ValidateNotSender(sender flow.Identifier) network.MessageValidator
ValidateNotSender creates and returns a validator which validates that the message origin id is different from sender id
func ValidateSender ¶
func ValidateSender(sender flow.Identifier) network.MessageValidator
ValidateSender creates and returns a new SenderValidator for the given sender ID
func ValidateTarget ¶
func ValidateTarget(log zerolog.Logger, target flow.Identifier) network.MessageValidator
ValidateTarget returns a new TargetValidator for the given target id
Types ¶
type AnyValidator ¶
type AnyValidator struct {
// contains filtered or unexported fields
}
AnyValidator returns true if any of the given validators returns true
func (AnyValidator) Validate ¶
func (v AnyValidator) Validate(msg network.IncomingMessageScope) bool
type AuthorizedSenderValidator ¶
type AuthorizedSenderValidator struct {
// contains filtered or unexported fields
}
AuthorizedSenderValidator performs message authorization validation.
func NewAuthorizedSenderValidator ¶
func NewAuthorizedSenderValidator(log zerolog.Logger, slashingViolationsConsumer slashing.ViolationsConsumer, getIdentity GetIdentityFunc) *AuthorizedSenderValidator
NewAuthorizedSenderValidator returns a new AuthorizedSenderValidator
func (*AuthorizedSenderValidator) PubSubMessageValidator ¶
func (av *AuthorizedSenderValidator) PubSubMessageValidator(channel channels.Channel) PubSubMessageValidator
PubSubMessageValidator wraps Validate and returns PubSubMessageValidator callback that returns pubsub.ValidationReject if validation fails and pubsub.ValidationAccept if validation passes.
func (*AuthorizedSenderValidator) Validate ¶
func (av *AuthorizedSenderValidator) Validate(from peer.ID, msg interface{}, channel channels.Channel, protocol message.Protocol) (string, error)
Validate will check if the sender of a message is authorized to send the message. Using the getIdentity to get the flow identity for the sender, asserting that the sender is a staked node and not ejected. Otherwise, the message is rejected. The message is also authorized by checking that the sender is allowed to send the message on the channel. If validation fails the message is rejected, and if the validation error is an expected error, slashing data is also collected. Authorization config is defined in message.MsgAuthConfig.
type MessageValidator ¶
MessageValidator validates the given message with original sender `from` and returns an error if validation fails else upon successful validation it should return the decoded message type string. Note: contrarily to pubsub.ValidatorEx, the peerID parameter does not represent the bearer of the message, but its source.
type NotValidator ¶
type NotValidator struct {
// contains filtered or unexported fields
}
NotValidator returns the opposite result of the given validator for the Validate call
func (NotValidator) Validate ¶
func (n NotValidator) Validate(msg network.IncomingMessageScope) bool
type OriginValidator ¶
type OriginValidator struct {
// contains filtered or unexported fields
}
OriginValidator returns true if the sender of the message is among the set of identifiers returned by the given IdentifierProvider
func (OriginValidator) Validate ¶
func (v OriginValidator) Validate(msg network.IncomingMessageScope) bool
type PubSubMessageValidator ¶
type PubSubMessageValidator func(from peer.ID, msg interface{}) p2p.ValidationResult
PubSubMessageValidator validates the given message with original sender `from` and returns p2p.ValidationResult. Note: contrarily to pubsub.ValidatorEx, the peerID parameter does not represent the bearer of the message, but its source.
type SenderValidator ¶
type SenderValidator struct {
// contains filtered or unexported fields
}
SenderValidator validates messages by sender ID
func (*SenderValidator) Validate ¶
func (sv *SenderValidator) Validate(msg network.IncomingMessageScope) bool
Validate returns true if the message origin id is the same as the sender ID.
type TargetValidator ¶
type TargetValidator struct {
// contains filtered or unexported fields
}
TargetValidator filters out messages by target ID
func (*TargetValidator) Validate ¶
func (tv *TargetValidator) Validate(msg network.IncomingMessageScope) bool
Validate returns true if the message is intended for the given target ID else it returns false