Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

types.gno

1.74 Kb · 50 lines
 1package validators
 2
 3import (
 4	"errors"
 5)
 6
 7// ValsetProtocol defines the validator set protocol (PoA / PoS / PoC / ?)
 8type ValsetProtocol interface {
 9	// AddValidator adds a new validator to the validator set.
10	// If the validator is already present, the method should error out
11	//
12	// TODO: This API is not ideal -- the address should be derived from
13	// the public key, and not be passed in as such, but currently Gno
14	// does not support crypto address derivation
15	AddValidator(address_XXX address, pubKey string, power uint64) (Validator, error)
16
17	// RemoveValidator removes the given validator from the set.
18	// If the validator is not present in the set, the method should error out
19	RemoveValidator(address_XXX address) (Validator, error)
20
21	// IsValidator returns a flag indicating if the given
22	// bech32 address is part of the validator set
23	IsValidator(address_XXX address) bool
24
25	// GetValidator returns the validator using the given address
26	GetValidator(address_XXX address) (Validator, error)
27
28	// GetValidators returns the currently active validator set
29	GetValidators() []Validator
30}
31
32// Validator represents a single chain validator
33type Validator struct {
34	Address     address // bech32 address
35	PubKey      string  // bech32 representation of the public key
36	VotingPower uint64
37}
38
39const (
40	ValidatorAddedEvent   = "ValidatorAdded"   // emitted when a validator was added to the set
41	ValidatorRemovedEvent = "ValidatorRemoved" // emitted when a validator was removed from the set
42)
43
44var (
45	// ErrValidatorExists is returned when the validator is already in the set
46	ErrValidatorExists = errors.New("validator already exists")
47
48	// ErrValidatorMissing is returned when the validator is not in the set
49	ErrValidatorMissing = errors.New("validator doesn't exist")
50)