voter

package
v0.22.8-patch-3-fix-co... Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Voter

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

Voter produces votes for the given block

func New

func New(
	signer hotstuff.SignerVerifier,
	forks hotstuff.ForksReader,
	persist hotstuff.Persister,
	committee hotstuff.Committee,
	lastVotedView uint64,
) *Voter

New creates a new Voter instance

func (*Voter) ProduceVoteIfVotable

func (v *Voter) ProduceVoteIfVotable(block *model.Block, curView uint64) (*model.Vote, error)

ProduceVoteIfVotable will make a decision on whether it will vote for the given proposal, the returned error indicates whether to vote or not. In order to ensure that only a safe node will be voted, Voter will ask Forks whether a vote is a safe node or not. The curView is taken as input to ensure Voter will only vote for proposals at current view and prevent double voting. This method will only ever _once_ return a `non-nil vote, nil` vote: the very first time it encounters a safe block of the

current view to vote for. Subsequently, voter does _not_ vote for any other block with the same (or lower) view.

(including repeated calls with the initial block we voted for also return `nil, error`).

Jump to

Keyboard shortcuts

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