validator

package
v0.26.14-test-synchron... Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthorizedSender

func IsAuthorizedSender(identity *flow.Identity, channel network.Channel, msg interface{}) (string, error)

IsAuthorizedSender checks if node is an authorized role.

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 AuthorizedSenderValidator added in v0.26.0

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

AuthorizedSenderValidator using the getIdentity func will check if the role of the sender is part of the authorized roles list for the channel being communicated on. A node is considered to be authorized to send a message if the following are true. 1. The node is staked. 2. The node is not ejected. 3. The message type is a known message type (can be decoded with network codec). 4. The message is authorized to be sent on channel. 4. The sender role is authorized to send message channel. 5. The sender role is authorized to participate on channel.

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