validator

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddValidatorToFile

func AddValidatorToFile(path string, v *Validator) error

AddValidatorToFile adds a validator `v` to the membership file `path`. If the file does not exist it will be created.

func SortByteSlices

func SortByteSlices(src [][]byte)

func SplitAndTrimEmpty

func SplitAndTrimEmpty(s, sep, cutset string) []string

Types

type OnChainValidators added in v0.1.5

type OnChainValidators struct {
	Validators  Set
	TotalWeight abi.TokenAmount
}

OnChainValidators information stored in the gateway actor

func NewOnChainValidatorsFromSet added in v0.1.5

func NewOnChainValidatorsFromSet(set *Set) OnChainValidators

func (*OnChainValidators) MarshalCBOR added in v0.1.5

func (t *OnChainValidators) MarshalCBOR(w io.Writer) error

func (*OnChainValidators) UnmarshalCBOR added in v0.1.5

func (t *OnChainValidators) UnmarshalCBOR(r io.Reader) (err error)

type Set

type Set struct {
	Validators          []*Validator `json:"validators"`
	ConfigurationNumber uint64       `json:"configuration_number"`
}

func NewEmptyValidatorSet added in v0.1.4

func NewEmptyValidatorSet() *Set

func NewValidatorSet

func NewValidatorSet(n uint64, vs []*Validator) *Set

func NewValidatorSetFromEnv

func NewValidatorSetFromEnv(env string) (*Set, error)

NewValidatorSetFromEnv initializes a validator set based on the data from the environment variable.

func NewValidatorSetFromFile

func NewValidatorSetFromFile(path string) (*Set, error)

NewValidatorSetFromFile reads a validator set based from the file.

func NewValidatorSetFromString

func NewValidatorSetFromString(s string) (*Set, error)

NewValidatorSetFromString reads a validator set from the string.

func NewValidatorSetFromValidators

func NewValidatorSetFromValidators(n uint64, vs ...*Validator) *Set

NewValidatorSetFromValidators creates a validator set from the validators.

func (*Set) AddValidator

func (s *Set) AddValidator(v *Validator)

func (*Set) Equal

func (s *Set) Equal(o *Set) bool

func (*Set) GetConfigurationNumber

func (s *Set) GetConfigurationNumber() uint64

func (*Set) GetValidatorIDs

func (s *Set) GetValidatorIDs() (ids []address.Address)

func (*Set) GetValidators

func (s *Set) GetValidators() []*Validator

func (*Set) HasValidatorWithID

func (s *Set) HasValidatorWithID(id string) bool

func (*Set) Hash

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

func (*Set) JSONString

func (s *Set) JSONString() string

func (*Set) MarshalCBOR

func (t *Set) MarshalCBOR(w io.Writer) error

func (*Set) Save

func (s *Set) Save(path string) error

Save saves the validator set to the file in JSON format.

func (*Set) Size

func (s *Set) Size() int

func (*Set) UnmarshalCBOR

func (t *Set) UnmarshalCBOR(r io.Reader) (err error)

type Validator

type Validator struct {
	Addr addr.Address `json:"addr"`
	// FIXME: Consider using a multiaddr
	NetAddr string           `json:"net_addr,omitempty"`
	Weight  *abi.TokenAmount `json:"weight,omitempty"`
}

func NewValidatorFromString

func NewValidatorFromString(s string) (*Validator, error)

NewValidatorFromString creates a validator based on the string in `Addr:Weight@NetworkAddr` format.

An examples of a validator string:

  • t1wpixt5mihkj75lfhrnaa6v56n27epvlgwparujy:10@/ip4/127.0.0.1/tcp/10000/p2p/12D3KooWJhKBXvytYgPCAaiRtiNLJNSFG5jreKDu2jiVpJetzvVJ

FIXME: Consider using json serde for this to support multiple multiaddr for validators.

func NewValidatorWithWeight added in v0.1.4

func NewValidatorWithWeight(a addr.Address, netAddr string, w *big.Int) *Validator

func (*Validator) Bytes

func (v *Validator) Bytes() ([]byte, error)

func (*Validator) Equal added in v0.1.4

func (v *Validator) Equal(o *Validator) bool

func (*Validator) ID

func (v *Validator) ID() string

func (*Validator) MarshalCBOR

func (t *Validator) MarshalCBOR(w io.Writer) error

func (*Validator) String

func (v *Validator) String() string

func (*Validator) UnmarshalCBOR

func (t *Validator) UnmarshalCBOR(r io.Reader) (err error)

Jump to

Keyboard shortcuts

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