validators

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// PutValidatorSet puts associaties the given subnet ID with the given validator set
	PutValidatorSet(ids.ID, Set)

	// RemoveValidatorSet removes the specified validator set
	RemoveValidatorSet(ids.ID)

	// GetGroup returns:
	// 1) the validator set of the subnet with the specified ID
	// 2) false if there is no subnet with the specified ID
	GetValidatorSet(ids.ID) (Set, bool)
}

Manager holds the validator set of each subnet

func NewManager

func NewManager() Manager

NewManager returns a new, empty manager

type Set

type Set interface {
	fmt.Stringer

	// Set removes all the current validators and adds all the provided
	// validators to the set.
	Set([]Validator)

	// Add the provided validator to the set.
	Add(Validator)

	// Get the validator from the set.
	Get(ids.ShortID) (Validator, bool)

	// Remove the validator with the specified ID.
	Remove(ids.ShortID)

	// Contains returns true if there is a validator with the specified ID
	// currently in the set.
	Contains(ids.ShortID) bool

	// Len returns the number of validators currently in the set.
	Len() int

	// List all the ids of validators in this group
	List() []Validator

	// Sample returns a collection of validator IDs. If there aren't enough
	// validators, the length of the returned validators may be less than
	// [size]. Otherwise, the length of the returned validators will equal
	// [size].
	Sample(size int) []Validator
}

Set of validators that can be sampled

func NewSet

func NewSet() Set

NewSet returns a new, empty set of validators.

type Validator

type Validator interface {
	// ID returns the unique id of this validator
	ID() ids.ShortID

	// Weight that can be used for weighted sampling.
	// If this validator is validating the default subnet, returns the amount of $AVA staked
	Weight() uint64
}

Validator is the minimal description of someone that can be sampled.

func GenerateRandomValidator

func GenerateRandomValidator(weight uint64) Validator

GenerateRandomValidator creates a random validator with the provided weight

func NewValidator

func NewValidator(id ids.ShortID, weight uint64) Validator

NewValidator returns a validator object that implements the Validator interface

Jump to

Keyboard shortcuts

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