Documentation
¶
Index ¶
- Constants
- Variables
- type GovernanceManager
- type Identity
- type PKI
- type Validator
- func LoadConfig(path string, listener rulesListener) ([]Validator, error)
- func LoadConfigContent(data []byte, listener rulesListener) ([]Validator, error)
- func LoadProcessRules(rules processesRules, listener rulesListener) ([]Validator, error)
- func NewMultiValidator(validators []Validator) Validator
Constants ¶
const (
// DefaultFilename is the default filename for the file with the rules of validation
DefaultFilename = "/data/validation/rules.json"
)
Variables ¶
var ( // ErrMissingProcess is returned when the process name is missing for validation. ErrMissingProcess = errors.New("validator requires a process") // ErrMissingLinkType is returned when the link type is missing for validation. ErrMissingLinkType = errors.New("validator requires a link type") )
var ( // ErrInvalidValidator is returned when the schema and the signatures are both missing in a validator. ErrInvalidValidator = errors.New("a validator requires a JSON schema, a signature or a transition criteria to be valid") // ErrBadPublicKey is returned when a public key is empty or not base64-encoded ErrBadPublicKey = errors.New("public key must be a non null base64 encoded string") // ErrNoPKI is returned when rules.json doesn't contain a `pki` field ErrNoPKI = errors.New("rules.json needs a 'pki' field to list authorized public keys") )
Functions ¶
This section is empty.
Types ¶
type GovernanceManager ¶ added in v0.3.0
type GovernanceManager struct {
// contains filtered or unexported fields
}
GovernanceManager manages governance for validation rules management.
func NewGovernanceManager ¶ added in v0.3.0
func NewGovernanceManager(ctx context.Context, a store.Adapter, filename string) (*GovernanceManager, error)
NewGovernanceManager enhances validator management with some governance concepts.
func (*GovernanceManager) UpdateValidators ¶ added in v0.3.0
func (m *GovernanceManager) UpdateValidators(ctx context.Context, v *Validator) bool
UpdateValidators will replace validator if a new one is available
type PKI ¶ added in v0.3.0
PKI maps a public key to an identity. It lists all legimate keys, assign real names to public keys and establishes n-to-n relationships between users and roles.
type Validator ¶
type Validator interface {
// Validate runs validations on a link and returns an error
// if the link is invalid.
Validate(context.Context, store.SegmentReader, *cs.Link) error
// ShouldValidate returns a boolean whether the link should be checked
ShouldValidate(*cs.Link) bool
// Hash returns the hash of the validator's state.
// It can be used to know which set of validations were applied
// to a block.
Hash() (*types.Bytes32, error)
}
Validator defines a validator that has an internal state, identified by its hash.
func LoadConfig ¶ added in v0.3.0
LoadConfig loads the validators configuration from a json file. The configuration returned can then be used in NewMultiValidator().
func LoadConfigContent ¶ added in v0.3.0
LoadConfigContent loads the validators configuration from json data. The configuration returned can then be used in NewMultiValidator().
func LoadProcessRules ¶ added in v0.3.0
LoadProcessRules loads the validators configuration from a slice of processRule. The configuration returned can then be used in NewMultiValidator().
func NewMultiValidator ¶ added in v0.3.0
NewMultiValidator creates a validator that will simply be a collection of single-purpose validators. The slice of validators should be loaded from a JSON file via validator.LoadConfig().