validator

package
v0.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2022 License: AGPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSenderEjected      = errors.New("validation failed: sender is an ejected node")
	ErrIdentityUnverified = errors.New("validation failed: could not verify identity of sender")
)

Functions

func AuthorizedSenderValidator added in v0.26.0

func AuthorizedSenderValidator(log zerolog.Logger, channel channels.Channel, getIdentity func(peer.ID) (*flow.Identity, bool)) validateFunc

AuthorizedSenderValidator returns a MessageValidator that will check if the sender of a message is authorized to send the message. The MessageValidator returned will use 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

func TopicValidator

func TopicValidator(log zerolog.Logger, codec network.Codec, peerFilter func(peer.ID) bool, validators ...MessageValidator) pubsub.ValidatorEx

Types

type MessageValidator

type MessageValidator func(ctx context.Context, from peer.ID, msg interface{}) pubsub.ValidationResult

MessageValidator validates the given message with original sender `from`. Note: contrarily to pubsub.ValidatorEx, the peerID parameter does not represent the bearer of the message, but its source.

func AuthorizedSenderMessageValidator added in v0.27.0

func AuthorizedSenderMessageValidator(log zerolog.Logger, channel channels.Channel, getIdentity func(peer.ID) (*flow.Identity, bool)) MessageValidator

AuthorizedSenderMessageValidator wraps the callback returned by AuthorizedSenderValidator and returns MessageValidator callback that returns pubsub.ValidationReject if validation fails and pubsub.ValidationAccept if validation passes.

type ValidatorData

type ValidatorData struct {
	Message           *message.Message
	DecodedMsgPayload interface{}
	From              peer.ID
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL