github.com/koko1123/flow-go-1@v0.29.6/network/validator/origin_validator.go (about) 1 package validator 2 3 import ( 4 "github.com/koko1123/flow-go-1/module" 5 "github.com/koko1123/flow-go-1/network" 6 ) 7 8 var _ network.MessageValidator = (*OriginValidator)(nil) 9 10 // OriginValidator returns true if the sender of the message is among the set of identifiers 11 // returned by the given IdentifierProvider 12 type OriginValidator struct { 13 idProvider module.IdentifierProvider 14 } 15 16 func NewOriginValidator(provider module.IdentifierProvider) network.MessageValidator { 17 return &OriginValidator{provider} 18 } 19 20 func (v OriginValidator) Validate(msg network.IncomingMessageScope) bool { 21 return v.idProvider.Identifiers().Contains(msg.OriginId()) 22 }