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
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
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 |
Click to show internal directories.
Click to hide internal directories.