leader

package
v0.37.10-migration-mai... Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const EstimatedSixMonthOfViews = 15000000 // 1 sec block time * 60 secs * 60 mins * 24 hours * 30 days * 6 months

Variables

This section is empty.

Functions

func IsInvalidViewError

func IsInvalidViewError(err error) bool

IsInvalidViewError returns whether or not the input error is an invalid view error.

Types

type InvalidViewError

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

InvalidViewError is returned when a requested view is outside the pre-computed range.

func (InvalidViewError) Error

func (err InvalidViewError) Error() string

type LeaderSelection

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

LeaderSelection caches the pre-generated leader selections for a certain number of views starting from the epoch start view.

func ComputeLeaderSelection added in v0.25.0

func ComputeLeaderSelection(
	firstView uint64,
	rng random.Rand,
	count int,
	identities flow.IdentitySkeletonList,
) (*LeaderSelection, error)

ComputeLeaderSelection pre-generates a certain number of leader selections, and returns a leader selection instance for querying the leader indexes for certain views. Inputs:

  • firstView: the start view of the epoch, the generated leader selections start from this view.
  • rng: the deterministic source of randoms
  • count: the number of leader selections to be pre-generated and cached.
  • identities the identities that contain the weight info, which is used as probability for the identity to be selected as leader.

Identities with `InitialWeight=0` are accepted as long as there are nodes with positive weights. Zero-weight nodes have zero probability of being selected as leaders in accordance with their weight.

func NewSelectionForBootstrap

func NewSelectionForBootstrap() *LeaderSelection

NewBootstrapLeaderSelection creates a leader selection for bootstrapping process to create genesis QC. The returned leader selection does not have any pre-generated leader selections since the bootstrapping process don't need it.

func SelectionForCluster

func SelectionForCluster(cluster protocol.Cluster, epoch protocol.Epoch) (*LeaderSelection, error)

SelectionForCluster pre-computes and returns leaders for the given cluster committee in the given epoch. A cluster containing nodes with zero `InitialWeight` is an accepted input as long as there are nodes with positive weights. Zero-weight nodes have zero probability of being selected as leaders in accordance with their weight.

func SelectionForConsensus

func SelectionForConsensus(initialIdentities flow.IdentitySkeletonList, randomSeed []byte, firstView, finalView uint64) (*LeaderSelection, error)

SelectionForConsensus pre-computes and returns leaders for the consensus committee in the given epoch. The consensus committee spans multiple epochs and the leader selection returned here is only valid for the input epoch, so it is necessary to call this for each upcoming epoch.

func SelectionForConsensusFromEpoch added in v0.37.1

func SelectionForConsensusFromEpoch(epoch protocol.Epoch) (*LeaderSelection, error)

SelectionForConsensusFromEpoch is a ...

func (LeaderSelection) FinalView

func (l LeaderSelection) FinalView() uint64

func (LeaderSelection) FirstView

func (l LeaderSelection) FirstView() uint64

func (LeaderSelection) LeaderForView

func (l LeaderSelection) LeaderForView(view uint64) (flow.Identifier, error)

LeaderForView returns the node ID of the leader for a given view. Returns InvalidViewError if the view is outside the pre-computed range.

Jump to

Keyboard shortcuts

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