Documentation ¶
Index ¶
- Variables
- type BLSValidator
- func (v *BLSValidator) Addr() types.Address
- func (v *BLSValidator) Bytes() []byte
- func (v *BLSValidator) Copy() Validator
- func (v *BLSValidator) Equal(vr Validator) bool
- func (v *BLSValidator) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
- func (v *BLSValidator) SetFromBytes(input []byte) error
- func (v *BLSValidator) String() string
- func (v *BLSValidator) Type() ValidatorType
- func (v *BLSValidator) UnmarshalRLPFrom(p *fastrlp.Parser, val *fastrlp.Value) error
- type BLSValidatorPublicKey
- type ECDSAValidator
- func (v *ECDSAValidator) Addr() types.Address
- func (v *ECDSAValidator) Bytes() []byte
- func (v *ECDSAValidator) Copy() Validator
- func (v *ECDSAValidator) Equal(vr Validator) bool
- func (v *ECDSAValidator) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
- func (v *ECDSAValidator) SetFromBytes(input []byte) error
- func (v *ECDSAValidator) String() string
- func (v *ECDSAValidator) Type() ValidatorType
- func (v *ECDSAValidator) UnmarshalRLPFrom(p *fastrlp.Parser, val *fastrlp.Value) error
- type Set
- func (s *Set) Add(val Validator) error
- func (s *Set) At(index uint64) Validator
- func (s *Set) Copy() Validators
- func (s *Set) Del(val Validator) error
- func (s *Set) Equal(ss Validators) bool
- func (s *Set) Includes(addr types.Address) bool
- func (s *Set) Index(addr types.Address) int64
- func (s *Set) Len() int
- func (s *Set) MarshalJSON() ([]byte, error)
- func (s *Set) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
- func (s *Set) Merge(ss Validators) error
- func (s *Set) Type() ValidatorType
- func (s *Set) UnmarshalJSON(data []byte) error
- func (s *Set) UnmarshalRLPFrom(p *fastrlp.Parser, val *fastrlp.Value) error
- type Validator
- type ValidatorType
- type Validators
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidValidatorType = errors.New("invalid validator type") ErrMismatchValidatorType = errors.New("mismatch between validator and validators") ErrMismatchValidatorsType = errors.New("mismatch between two validators") ErrValidatorAlreadyExists = errors.New("validator already exists in validators") ErrValidatorNotFound = errors.New("validator not found in validators") ErrInvalidValidators = errors.New("container is not ") )
var (
ErrInvalidBLSValidatorFormat = errors.New("invalid validator format, expected [Validator Address]:[BLS Public Key]")
)
var (
ErrInvalidTypeAssert = errors.New("invalid type assert")
)
Functions ¶
This section is empty.
Types ¶
type BLSValidator ¶
type BLSValidator struct { Address types.Address BLSPublicKey BLSValidatorPublicKey }
BLSValidator is a validator using BLS signing algorithm
func NewBLSValidator ¶
func NewBLSValidator(addr types.Address, blsPubkey []byte) *BLSValidator
NewBLSValidator is a constructor of BLSValidator
func ParseBLSValidator ¶
func ParseBLSValidator(validator string) (*BLSValidator, error)
ParseBLSValidator parses BLSValidator represented in string
func (*BLSValidator) Addr ¶
func (v *BLSValidator) Addr() types.Address
Addr returns the validator address
func (*BLSValidator) Bytes ¶
func (v *BLSValidator) Bytes() []byte
Bytes returns bytes of BLSValidator in RLP encode
func (*BLSValidator) Copy ¶
func (v *BLSValidator) Copy() Validator
Copy returns copy of BLS Validator
func (*BLSValidator) Equal ¶
func (v *BLSValidator) Equal(vr Validator) bool
Equal checks the given validator matches with its data
func (*BLSValidator) MarshalRLPWith ¶
func (v *BLSValidator) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith is a RLP Marshaller
func (*BLSValidator) SetFromBytes ¶
func (v *BLSValidator) SetFromBytes(input []byte) error
SetFromBytes parses given bytes in RLP encode and map to its fields
func (*BLSValidator) String ¶
func (v *BLSValidator) String() string
String returns string representation of BLSValidator Format => [Address]:[BLSPublicKey]
func (*BLSValidator) Type ¶
func (v *BLSValidator) Type() ValidatorType
Type returns the ValidatorType of BLSValidator
func (*BLSValidator) UnmarshalRLPFrom ¶
UnmarshalRLPFrom is a RLP Unmarshaller
type BLSValidatorPublicKey ¶
type BLSValidatorPublicKey []byte
func (BLSValidatorPublicKey) MarshalText ¶
func (k BLSValidatorPublicKey) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler
func (BLSValidatorPublicKey) String ¶
func (k BLSValidatorPublicKey) String() string
String returns a public key in hex
func (*BLSValidatorPublicKey) UnmarshalText ¶
func (k *BLSValidatorPublicKey) UnmarshalText(input []byte) error
UnmarshalText parses an BLS Public Key in hex
type ECDSAValidator ¶
BLSValidator is a validator using ECDSA signing algorithm
func NewECDSAValidator ¶
func NewECDSAValidator(addr types.Address) *ECDSAValidator
NewECDSAValidator is a constructor of ECDSAValidator
func ParseECDSAValidator ¶
func ParseECDSAValidator(validator string) *ECDSAValidator
ParseBLSValidator parses ECDSAValidator represented in string
func (*ECDSAValidator) Addr ¶
func (v *ECDSAValidator) Addr() types.Address
Addr returns the validator address
func (*ECDSAValidator) Bytes ¶
func (v *ECDSAValidator) Bytes() []byte
Bytes returns bytes of ECDSAValidator
func (*ECDSAValidator) Copy ¶
func (v *ECDSAValidator) Copy() Validator
Copy returns copy of ECDSAValidator
func (*ECDSAValidator) Equal ¶
func (v *ECDSAValidator) Equal(vr Validator) bool
Equal checks the given validator matches with its data
func (*ECDSAValidator) MarshalRLPWith ¶
func (v *ECDSAValidator) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith is a RLP Marshaller
func (*ECDSAValidator) SetFromBytes ¶
func (v *ECDSAValidator) SetFromBytes(input []byte) error
SetFromBytes parses given bytes
func (*ECDSAValidator) String ¶
func (v *ECDSAValidator) String() string
String returns string representation of ECDSAValidator
func (*ECDSAValidator) Type ¶
func (v *ECDSAValidator) Type() ValidatorType
Type returns the ValidatorType of ECDSAValidator
func (*ECDSAValidator) UnmarshalRLPFrom ¶
UnmarshalRLPFrom is a RLP Unmarshaller
type Set ¶
type Set struct { ValidatorType ValidatorType Validators []Validator }
func (*Set) Equal ¶
func (s *Set) Equal(ss Validators) bool
Equal checks the given validators matches with its data
func (*Set) Includes ¶
Includes return the bool indicating whether the validator whose address matches with the given address exists or not
func (*Set) Index ¶
Index returns the index of the validator whose address matches with the given address
func (*Set) MarshalJSON ¶
Marshal implements json marshal function
func (*Set) MarshalRLPWith ¶
MarshalRLPWith is a RLP Marshaller
func (*Set) Merge ¶
func (s *Set) Merge(ss Validators) error
Merge introduces the given collection into its collection
func (*Set) UnmarshalJSON ¶
UnmarshalJSON implements json unmarshal function
type Validator ¶
type Validator interface { // Return the validator type Type() ValidatorType // Return the string representation String() string // Return the address of the validator Addr() types.Address // Return of copy of the validator Copy() Validator // Check the same validator or not Equal(Validator) bool // RLP Marshaller to encode to bytes MarshalRLPWith(*fastrlp.Arena) *fastrlp.Value // RLP Unmarshaller to encode from bytes UnmarshalRLPFrom(*fastrlp.Parser, *fastrlp.Value) error // Return bytes in RLP encode Bytes() []byte // Decode bytes in RLP encode and map to the fields SetFromBytes([]byte) error }
Validator defines the interface of the methods a validator implements
func NewValidatorFromType ¶
func NewValidatorFromType(t ValidatorType) (Validator, error)
NewValidatorFromType instantiates a validator by specified type
func ParseValidator ¶
func ParseValidator(validatorType ValidatorType, validator string) (Validator, error)
ParseValidator parses a validator represented in string
type ValidatorType ¶
type ValidatorType string
const ( ECDSAValidatorType ValidatorType = "ecdsa" BLSValidatorType ValidatorType = "bls" )
func ParseValidatorType ¶
func ParseValidatorType(validatorType string) (ValidatorType, error)
ParseValidatorType converts a validatorType string representation to a ValidatorType
type Validators ¶
type Validators interface { // Return the type of the validators Type() ValidatorType // Return the size of collection Len() int // Check equality of each element Equal(Validators) bool // Return of the whole collection Copy() Validators // Get validator at specified height At(uint64) Validator // Find the index of the validator that has specified address Index(types.Address) int64 // Check the validator that has specified address exists in the collection Includes(types.Address) bool // Add a validator into collection Add(Validator) error // Remove a validator from collection Del(Validator) error // Merge 2 collections into one collection Merge(Validators) error // RLP Marshaller to encode to bytes MarshalRLPWith(*fastrlp.Arena) *fastrlp.Value // Decode bytes in RLP encode and map to the elements UnmarshalRLPFrom(*fastrlp.Parser, *fastrlp.Value) error }
Validators defines the interface of the methods validator collection implements
func NewBLSValidatorSet ¶
func NewBLSValidatorSet(blsValidators ...*BLSValidator) Validators
NewBLSValidatorSet creates Validator Set for BLSValidator with initialized validators
func NewECDSAValidatorSet ¶
func NewECDSAValidatorSet(ecdsaValidators ...*ECDSAValidator) Validators
NewECDSAValidatorSet creates Validator Set for ECDSAValidator with initialized validators
func NewValidatorSetFromType ¶
func NewValidatorSetFromType(t ValidatorType) Validators
NewValidatorSetFromType instantiates a validators by specified type
func ParseValidators ¶
func ParseValidators(validatorType ValidatorType, rawValidators []string) (Validators, error)
ParseValidator parses an array of validator represented in string