leader

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UnknownLeader = ""

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockLoader

type BlockLoader func(round uint64) (*storage.ExecutedBlock, error)

type ReputationBased

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

ReputationBased implements reputation based leader election strategy. Zero value is not usable, use constructor!

Remarks:

  • same leader might be elected for up to three consecutive rounds - leader of the round R is not eligible to be leader for rounds [R+3 .. R+3+excludeSize-1];

func NewReputationBased

func NewReputationBased(validators []peer.ID, windowSize, excludeSize int) (*ReputationBased, error)

NewReputationBased creates "leader election based on reputation" strategy implementation.

  • "validators" is (sorted!) list of peer IDs to use for round-robin leader selection when there is no elected leader for the round;
  • the "windowSize" is number of committed blocks to use to determine list of active validators (ie those which voted). It must not be larger than the "block history" available to the blockLoader, IOW the "blockLoader" must be able to return blocks at least inside the window.
  • "excludeSize" is the number of most recent block authors to exclude form candidate list when electing leader for the next round. Generally should be between f and 2f (where f is max allowed number of faulty nodes).

func (*ReputationBased) GetLeaderForRound

func (rb *ReputationBased) GetLeaderForRound(round uint64) peer.ID

GetLeaderForRound returns either elected leader or (in case the round doesn't have elected leader) falls back to round-robin of all validators. Undefined behavior for round==0.

func (*ReputationBased) GetNodes

func (rb *ReputationBased) GetNodes() []peer.ID

GetNodes returns all currently active root nodes

func (*ReputationBased) Update

func (rb *ReputationBased) Update(qc *abtypes.QuorumCert, currentRound uint64, blockLoader BlockLoader) error

Update triggers leader election for the next round. Returns error when election fails or QC and currentRound combination does not trigger election. "currentRound" - what PaceMaker considers to be the current round at the time QC is processed. "blockLoader" - a callback into block store which allows to load block data of given round, it is expected to return either valid block or error.

type RoundRobin

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

func NewRoundRobin

func NewRoundRobin(validators []peer.ID, contRounds uint32) (*RoundRobin, error)

NewRoundRobin returns round-robin leader selection algorithm based on node identifiers. It is assumed that the order of node identifiers is the same (e.g. alphabetical) for all validators. "contRounds" - for how many continuous rounds each peer is considered to be the leader.

func (*RoundRobin) GetLeaderForRound

func (r *RoundRobin) GetLeaderForRound(round uint64) peer.ID

func (*RoundRobin) GetNodes

func (r *RoundRobin) GetNodes() []peer.ID

GetNodes returns all currently active root nodes

func (*RoundRobin) Update

func (r *RoundRobin) Update(qc *abtypes.QuorumCert, currentRound uint64, b BlockLoader) error

Jump to

Keyboard shortcuts

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