voter

package
v0.26.16-access-txresu... Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: AGPL-3.0 Imports: 3 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.Signer,
	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. Returns:

  • (vote, nil): On the _first_ block for the current view that is safe to vote for. Subsequently, voter does _not_ vote for any other block with the same (or lower) view.
  • (nil, model.NoVoteError): If the voter decides that it does not want to vote for the given block. This is a sentinel error and _expected_ during normal operation.

All other errors are unexpected and potential symptoms of uncovered edge cases or corrupted internal state (fatal).

Jump to

Keyboard shortcuts

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