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.