Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrZeroWeight = errors.New("weight must be non-zero") ErrMissingValidators = errors.New("missing validators") )
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector interface { Connected( ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application, ) error Disconnected(ctx context.Context, nodeID ids.NodeID) error }
Connector represents a handler that is called when a connection is marked as connected or disconnected
type GetValidatorOutput ¶ added in v1.9.4
GetValidatorOutput is a struct that contains the publicly relevant values of a validator of the Avalanche Network for the output of GetValidator.
type Manager ¶
type Manager interface { fmt.Stringer // Add a new staker to the subnet. // Returns an error if: // - [weight] is 0 // - [nodeID] is already in the validator set // If an error is returned, the set will be unmodified. AddStaker(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error // AddWeight to an existing staker to the subnet. // Returns an error if: // - [weight] is 0 // - [nodeID] is not already in the validator set // If an error is returned, the set will be unmodified. // AddWeight can result in a total weight that overflows uint64. // In this case no error will be returned for this call. // However, the next TotalWeight call will return an error. AddWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error // GetWeight retrieves the validator weight from the subnet. GetWeight(subnetID ids.ID, nodeID ids.NodeID) uint64 // GetValidator returns the validator tied to the specified ID in subnet. // If the validator doesn't exist, returns false. GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*Validator, bool) // GetValidatorIDs returns the validator IDs in the subnet. GetValidatorIDs(subnetID ids.ID) []ids.NodeID // SubsetWeight returns the sum of the weights of the validators in the subnet. // Returns err if subset weight overflows uint64. SubsetWeight(subnetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error) // RemoveWeight from a staker in the subnet. If the staker's weight becomes 0, the staker // will be removed from the subnet set. // Returns an error if: // - [weight] is 0 // - [nodeID] is not already in the subnet set // - the weight of the validator would become negative // If an error is returned, the set will be unmodified. RemoveWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error // NumSubnets returns the number of subnets with non-zero weight. NumSubnets() int // NumValidators returns the number of validators currently in the subnet. NumValidators(subnetID ids.ID) int // TotalWeight returns the cumulative weight of all validators in the subnet. // Returns err if total weight overflows uint64. TotalWeight(subnetID ids.ID) (uint64, error) // Sample returns a collection of validatorIDs in the subnet, potentially with duplicates. // If sampling the requested size isn't possible, an error will be returned. Sample(subnetID ids.ID, size int) ([]ids.NodeID, error) // Map of the validators in this subnet GetMap(subnetID ids.ID) map[ids.NodeID]*GetValidatorOutput // When a validator is added, removed, or its weight changes, the listener // will be notified of the event. RegisterCallbackListener(listener ManagerCallbackListener) // When a validator is added, removed, or its weight changes on [subnetID], // the listener will be notified of the event. RegisterSetCallbackListener(subnetID ids.ID, listener SetCallbackListener) }
Manager holds the validator set of each subnet
type ManagerCallbackListener ¶ added in v1.11.9
type ManagerCallbackListener interface { OnValidatorAdded(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) OnValidatorRemoved(subnetID ids.ID, nodeID ids.NodeID, weight uint64) OnValidatorWeightChanged(subnetID ids.ID, nodeID ids.NodeID, oldWeight, newWeight uint64) }
type SetCallbackListener ¶ added in v1.8.4
type State ¶
type State interface { // GetMinimumHeight returns the minimum height of the block still in the // proposal window. GetMinimumHeight(context.Context) (uint64, error) // GetCurrentHeight returns the current height of the P-chain. GetCurrentHeight(context.Context) (uint64, error) // GetSubnetID returns the subnetID of the provided chain. GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error) // GetValidatorSet returns the validators of the provided subnet at the // requested P-chain height. // The returned map should not be modified. GetValidatorSet( ctx context.Context, height uint64, subnetID ids.ID, ) (map[ids.NodeID]*GetValidatorOutput, error) // GetCurrentValidatorSet returns the current validators of the provided subnet // and the current P-Chain height. // Map is keyed by ValidationID. GetCurrentValidatorSet( ctx context.Context, subnetID ids.ID, ) (map[ids.ID]*GetCurrentValidatorOutput, uint64, error) }
State allows the lookup of validator sets on specified subnets at the requested P-chain height.
func NewNoValidatorsState ¶ added in v1.8.4
Source Files ¶
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.