poll

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 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 Poll

type Poll interface {
	// ID returns the poll ID
	ID() uint32

	// Vote registers a vote
	Vote(nodeID ids.NodeID, vote Vote) error

	// Drop removes a node from the poll
	Drop(nodeID ids.NodeID) error

	// Finished returns true if the poll is finished
	Finished() bool

	// Result returns the poll result if finished
	Result() (Result, error)

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

Poll represents a consensus poll

func NewPoll

func NewPoll(id uint32, voters set.Set[ids.NodeID]) Poll

NewPoll creates a new poll

type Result

type Result struct {
	PreferredID     ids.ID
	AcceptedID      ids.ID
	PreferenceCount int
	AcceptanceCount int
}

Result represents the result of a poll

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set manages a set of polls

func NewSet

func NewSet() *Set

NewSet creates a new poll set

func (*Set) Add

func (s *Set) Add(requestID uint32, poll Poll) error

Add adds a new poll

func (*Set) Drop

func (s *Set) Drop(requestID uint32, nodeID ids.NodeID) error

Drop removes a node from a poll

func (*Set) Get

func (s *Set) Get(requestID uint32) (Poll, bool)

Get returns a poll by ID

func (*Set) Len

func (s *Set) Len() int

Len returns the number of active polls

func (*Set) Remove

func (s *Set) Remove(requestID uint32) error

Remove removes a finished poll

func (*Set) Vote

func (s *Set) Vote(requestID uint32, nodeID ids.NodeID, vote Vote) error

Vote registers a vote

type Vote

type Vote struct {
	PreferredID ids.ID
	AcceptedID  ids.ID
}

Vote represents a vote in a poll

Jump to

Keyboard shortcuts

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