validators

package
v0.0.0-...-5839da9 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 ")
)
View Source
var (
	ErrInvalidBLSValidatorFormat = errors.New("invalid validator format, expected [Validator Address]:[BLS Public Key]")
)
View Source
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

func (v *BLSValidator) UnmarshalRLPFrom(p *fastrlp.Parser, val *fastrlp.Value) error

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

type ECDSAValidator struct {
	Address types.Address
}

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

func (v *ECDSAValidator) UnmarshalRLPFrom(p *fastrlp.Parser, val *fastrlp.Value) error

UnmarshalRLPFrom is a RLP Unmarshaller

type Set

type Set struct {
	ValidatorType ValidatorType
	Validators    []Validator
}

func (*Set) Add

func (s *Set) Add(val Validator) error

Add adds a validator into the collection

func (*Set) At

func (s *Set) At(index uint64) Validator

At returns a validator at specified index in the collection

func (*Set) Copy

func (s *Set) Copy() Validators

Copy returns a copy of BLSValidators

func (*Set) Del

func (s *Set) Del(val Validator) error

Del removes a validator from the collection

func (*Set) Equal

func (s *Set) Equal(ss Validators) bool

Equal checks the given validators matches with its data

func (*Set) Includes

func (s *Set) Includes(addr types.Address) bool

Includes return the bool indicating whether the validator whose address matches with the given address exists or not

func (*Set) Index

func (s *Set) Index(addr types.Address) int64

Index returns the index of the validator whose address matches with the given address

func (*Set) Len

func (s *Set) Len() int

Len returns the size of its collection

func (*Set) MarshalJSON

func (s *Set) MarshalJSON() ([]byte, error)

Marshal implements json marshal function

func (*Set) MarshalRLPWith

func (s *Set) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith is a RLP Marshaller

func (*Set) Merge