leader

package
v0.29.17-read-leaf-nodes Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 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.IdentityList,
) (*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. 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.

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.

func SelectionForConsensus

func SelectionForConsensus(epoch protocol.Epoch) (*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 (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