selectproposer

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStore

type BlockStore interface {
	LoadBlockMeta(height int64) *types.BlockMeta
	Base() int64
}

type ProposerSelector

type ProposerSelector interface {
	// GetProposer returns the proposer for the given height and round. It calls Update if necessary.
	GetProposer(height int64, round int32) (*types.Validator, error)

	// MustGetProposer returns the proposer for the given height and round. It calls Update if necessary.
	// It panics on any error.
	//
	// Only use in tests.
	// See [GetProposer](#GetProposer) for details.
	MustGetProposer(height int64, round int32) *types.Validator
	// UpdateHeightRound updates proposer to match provided height and round. It should be called at least once for each round.
	//   - `height` is the height
	//  - `round` is the round
	UpdateHeightRound(height int64, round int32) error
	// Returns pointer to underlying validator set; not thread-safe, and should be modified with caution
	ValidatorSet() *types.ValidatorSet
	// Create deep copy of the strategy and its underlying validator set
	Copy() ProposerSelector
}

func NewHeightProposerSelector

func NewHeightProposerSelector(vset *types.ValidatorSet, currentHeight int64, bs BlockStore, logger log.Logger) (ProposerSelector, error)

NewHeightProposerSelector creates a new height-based proposer selector.

This selector goes through validators in a round-robin approach, increasing proposer index by 1 at each height.

Subsequent rounds at the same height will select next proposer on the list, but not persist these changes, so that the proposer of height H and round 1 is selected again at height H+1 and round 0.

It modifies `valSet` in place.

## Arguments

* `vset` - the validator set; it must not be empty and can be modified in place * `currentHeight` - the current height for which vset has correct scores * `bs` - block store used to retrieve info about historical commits * `logger` - logger to use

func NewHeightRoundProposerSelector

func NewHeightRoundProposerSelector(vset *types.ValidatorSet, currentHeight int64, currentRound int32, bs BlockStore, logger log.Logger) (ProposerSelector, error)

NewHeightRoundProposerSelector creates a new proposer selector that goes around the validator set and ensures every proposer votes once.

Each height and round increases proposer index. For example, that if a proposer is selected at height H and round R and the block is committed, next proposer will be selected at height H+1 and round 0 (contrary to heightProposerSelector).

It modifies `valSet` in place.

## Arguments

* `vset` - the validator set; it must not be empty and can be modified in place * `currentHeight` - the current height for which vset has correct scores * `currentRound` - the current round for which vset has correct scores * `bs` - the block store to use for historical data; can be nil * `logger` - the logger to use; can be nil

func NewProposerSelector

func NewProposerSelector(cp types.ConsensusParams, valSet *types.ValidatorSet, valsetHeight int64, valsetRound int32,
	bs BlockStore, logger log.Logger) (ProposerSelector, error)

NewProposerSelector creates an instance of ProposerSelector based on the given ConsensusParams.

Original ValidatorSet should not be used anymore. Height and round should point to the height and round that is reflected in validator scores, eg. the one for which GetProposer() returns proposer that generates proposal at the given height and round.

If block store is provided, it will be used to determine the proposer for the current height.

## Arguments

- `cp` - ConsensusParams that determine scoring strategy to use - `valSet` - validator set to use - `valsetHeight` - current height of the validator set - `valsetRound` - current round of the validator set - `bs` - block store used to retreve info about historical commits - `logger` - logger to use; can be nil

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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