validators

package
v1.0.0-genesis Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingValidators indicates no validators are present
	ErrMissingValidators = errors.New("missing validators")
)

Functions

This section is empty.

Types

type Manager

type Manager interface {
	fmt.Stringer

	// Add a new validator to the subnet.
	Add(nodeID ids.NodeID, publicKey *bls.PublicKey, txID ids.ID, weight uint64) error

	// AddWeight to an existing validator.
	AddWeight(nodeID ids.NodeID, weight uint64) error

	// GetWeight retrieves the validator weight from the subnet.
	GetWeight(nodeID ids.NodeID) uint64

	// GetValidator returns the validator tied to the specified ID.
	GetValidator(nodeID ids.NodeID) (*Validator, bool)

	// GetValidatorIDs returns the validator IDs in this subnet.
	GetValidatorIDs() []ids.NodeID

	// SubsetWeight returns the sum of the weights of the validators in the subset.
	SubsetWeight(nodeIDs []ids.NodeID) (uint64, error)

	// RemoveWeight from a validator.
	RemoveWeight(nodeID ids.NodeID, weight uint64) error

	// Remove a validator from the subnet.
	Remove(nodeID ids.NodeID) error

	// TotalWeight returns the cumulative weight of all validators.
	TotalWeight() uint64

	// Count returns the number of validators currently in the subnet.
	Count() int

	// Sample returns a collection of validatorIDs, potentially with duplicates.
	// If sampling the requested size isn't possible, an error will be returned.
	Sample(size int) ([]ids.NodeID, error)

	// Map of the validators in this subnet
	Map() map[ids.NodeID]*Validator
}

Manager holds the validator set of each subnet

func NewManager

func NewManager() Manager

NewManager returns a new, empty manager

type SetState

type SetState interface {
	Manager

	// GetCurrentHeight returns the current height
	GetCurrentHeight() (uint64, error)

	// GetValidatorSet returns the validator set of the given subnet at the
	// given height
	GetValidatorSet(height uint64, subnetID ids.ID) (map[ids.NodeID]*Validator, error)
}

SetState represents a mutable validator set

type State added in v1.11.10

type State interface {
	// GetValidatorSet returns the validator set of [subnetID] at [pChainHeight].
	// If the P-chain height is [math.MaxUint64], then the current validator set
	// is returned.
	GetValidatorSet(
		pChainHeight uint64,
		subnetID ids.ID,
	) (map[ids.NodeID]*Validator, error)
}

State allows the lookup of validator sets on specified subnets at the requested P-chain height.

type TestState added in v1.11.10

type TestState interface {
	State

	// SetValidator sets the validator for the given subnet and height
	SetValidator(pChainHeight uint64, subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
}

TestState is a test validator state

type Validator

type Validator struct {
	NodeID    ids.NodeID
	PublicKey *bls.PublicKey
	TxID      ids.ID
	Weight    uint64
}

Validator contains the base set of fields describing a validator

func (*Validator) Less

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

Less returns true if this validator's ID is less than the other's

Directories

Path Synopsis
Package validatorsmock provides mock implementations for validators
Package validatorsmock provides mock implementations for validators
Package validatorstest provides test utilities for validators
Package validatorstest provides test utilities for validators

Jump to

Keyboard shortcuts

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