validator

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFilename is the default filename for the file with the rules of validation
	DefaultFilename = "/data/validation/rules.json"
)

Variables

View Source
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")
)
View Source
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 Identity added in v0.3.0

type Identity struct {
	Keys  []string
	Roles []string
}

Identity represents an actor of an indigo network

type PKI added in v0.3.0

type PKI map[string]*Identity

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

func LoadConfig(path string, listener rulesListener) ([]Validator, error)

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

func LoadConfigContent(data []byte, listener rulesListener) ([]Validator, error)

LoadConfigContent loads the validators configuration from json data. The configuration returned can then be used in NewMultiValidator().

func LoadProcessRules added in v0.3.0

func LoadProcessRules(rules processesRules, listener rulesListener) ([]Validator, error)

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

func NewMultiValidator(validators []Validator) Validator

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().

Jump to

Keyboard shortcuts

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