validators

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetValidatorOutput

type GetValidatorOutput struct {
	NodeID    ids.NodeID
	PublicKey *bls.PublicKey
	Weight    uint64
}

GetValidatorOutput is the output of GetValidator

type Set

type Set interface {
	// Add adds a validator
	Add(nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error

	// AddWeight adds weight to a validator
	AddWeight(nodeID ids.NodeID, weight uint64) error

	// Get returns a validator's weight
	Get(nodeID ids.NodeID) (uint64, bool)

	// GetWeight returns a validator's weight
	GetWeight(nodeID ids.NodeID) uint64

	// SubsetWeight returns the total weight of a subset
	SubsetWeight(subset []ids.NodeID) uint64

	// Remove removes a validator
	Remove(nodeID ids.NodeID) error

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

	// Contains returns true if the validator is in the set
	Contains(nodeID ids.NodeID) bool

	// Len returns the number of validators
	Len() int

	// List returns all validator IDs
	List() []ids.NodeID

	// Weight returns the total weight
	Weight() uint64

	// Sample returns a sample of validators
	Sample(size int) ([]ids.NodeID, error)

	// String returns a string representation
	String() string
}

Set manages a set of validators

func NewSet

func NewSet() Set

NewSet creates a new validator set

type State

type State interface {
	// GetValidatorSet returns the validator set for a subnet at a given height
	GetValidatorSet(
		ctx interface{},
		height uint64,
		subnetID ids.ID,
	) (map[ids.NodeID]*GetValidatorOutput, error)

	// GetValidator returns a validator's info
	GetValidator(
		ctx interface{},
		subnetID ids.ID,
		nodeID ids.NodeID,
	) (*GetValidatorOutput, error)
}

State manages the validator set state

Jump to

Keyboard shortcuts

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