Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrValidatorNotFound = errors.New("validator not found") ErrInvalidWeight = errors.New("invalid weight") )
View Source
var ( // PrimaryNetworkID is the ID of the primary network PrimaryNetworkID = constants.PrimaryNetworkID )
For compatibility with node expectations
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface {
// Connected is called when a validator connects
Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
// Disconnected is called when a validator disconnects
Disconnected(ctx context.Context, nodeID ids.NodeID) error
}
Connector handles validator connection events
type GetValidatorOutput ¶
GetValidatorOutput is a struct that contains the publicly relevant values of a validator of the Lux primary network or a Lux subnet.
type Manager ¶
type Manager interface {
fmt.Stringer
// Add a subnet's validator set to the manager.
Add(subnetID ids.ID, validators Set) error
// Remove a subnet's validator set from the manager.
Remove(subnetID ids.ID) error
// Contains returns true if the manager is tracking the validator set for the given subnet.
Contains(subnetID ids.ID) bool
// Get returns the validator set for the given subnet.
Get(subnetID ids.ID) (Set, bool)
// GetByWeight returns a new validator set for the given subnet that contains all
// validators with at least the given weight.
GetByWeight(subnetID ids.ID, minWeight uint64) (Set, bool)
// GetWeight returns the weight of a specific validator for the given subnet.
GetWeight(subnetID ids.ID, nodeID ids.NodeID) uint64
// TotalWeight returns the total weight of all validators for the given subnet.
TotalWeight(subnetID ids.ID) (uint64, error)
// RecalculateStakes recalculates the stakes of all validators in the validator set.
RecalculateStakes(subnetID ids.ID) error
// Count returns the number of subnets that have validator sets.
Count() int
// GetValidator returns information about a validator
GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*Validator, error)
}
Manager manages validator sets for different subnets.
type Set ¶
type Set interface {
// Add adds a validator to the set.
Add(nodeID ids.NodeID, pk []byte, weight uint64) error
// AddWeight adds weight to a validator in the set.
AddWeight(nodeID ids.NodeID, weight uint64) error
// RemoveWeight removes weight from a validator in the set.
RemoveWeight(nodeID ids.NodeID, weight uint64) error
// Remove removes a validator from the set.
Remove(nodeID ids.NodeID) error
// Contains returns true if the set contains the given nodeID.
Contains(nodeID ids.NodeID) bool
// Get returns the validator with the given nodeID.
Get(nodeID ids.NodeID) (*Validator, bool)
// Len returns the number of validators in the set.
Len() int
// List returns the validators in this set
List() []*Validator
// Weight returns the total weight of the validator set.
Weight() uint64
// Sample returns a random validator from the set, weighted by stake.
Sample(seed uint64) (ids.NodeID, error)
// String returns a string representation of the set.
String() string
}
Set is a set of validators with each validator having a weight.
type State ¶
type State interface {
// GetMinimumHeight returns the minimum height of the P-chain.
GetMinimumHeight(ctx context.Context) (uint64, error)
// GetCurrentHeight returns the current height of the P-chain.
GetCurrentHeight(ctx context.Context) (uint64, error)
// GetSubnetID returns the subnet ID for the given chain ID.
GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
// GetValidatorSet returns the validators of the given subnet at the
// given P-chain height.
// Returns [database.ErrNotFound] if the validator set doesn't exist.
GetValidatorSet(
ctx context.Context,
height uint64,
subnetID ids.ID,
) (map[ids.NodeID]*GetValidatorOutput, error)
}
State allows getting a weighted validator set on a given subnet for a given P-chain height.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package validatorsmock is a generated GoMock package.
|
Package validatorsmock is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.