voter

package
v0.22.9-patch-1-epoch-... Latest Latest
Warning

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

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

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