version

package
v0.37.3-pr6271 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfRange = errors.New("height is out of range")

ErrOutOfRange indicates that height is higher than last handled block height

View Source
var NoHeight = uint64(0)

NoHeight represents the maximum possible height for blocks.

Functions

This section is empty.

Types

type VersionControl

type VersionControl struct {
	// Noop implements the protocol.Consumer interface with no operations.
	psEvents.Noop
	sync.Mutex
	component.Component
	// contains filtered or unexported fields
}

VersionControl manages the version control system for the node. It consumes BlockFinalized events and updates the node's version control based on the latest version beacon.

VersionControl implements the protocol.Consumer and component.Component interfaces.

func NewVersionControl

func NewVersionControl(
	log zerolog.Logger,
	versionBeacons storage.VersionBeacons,
	nodeVersion *semver.Version,
	sealedRootBlockHeight uint64,
	latestFinalizedBlockHeight uint64,
) (*VersionControl, error)

NewVersionControl creates a new VersionControl instance.

We currently have no strong guarantee that the node version is a valid semver. See build.SemverV2 for more details. That is why nil is a valid input for node version.

func (*VersionControl) AddVersionUpdatesConsumer

func (v *VersionControl) AddVersionUpdatesConsumer(consumer VersionControlConsumer)

AddVersionUpdatesConsumer adds a consumer for version update events.

func (*VersionControl) BlockFinalized

func (v *VersionControl) BlockFinalized(h *flow.Header)

BlockFinalized is called when a block is finalized. It implements the protocol.Consumer interface.

func (*VersionControl) CompatibleAtBlock

func (v *VersionControl) CompatibleAtBlock(height uint64) (bool, error)

CompatibleAtBlock checks if the node's version is compatible at a given block height. It returns true if the node's version is compatible within the specified height range. Returns expected errors: - ErrOutOfRange if incoming block height is higher that last handled block height

type VersionControlConsumer

type VersionControlConsumer func(height uint64, version *semver.Version)

VersionControlConsumer defines a function type that consumes version control updates. It is called with the block height and the corresponding semantic version. There are two possible notifications options: - A new or updated version will have a height and a semantic version at that height. - A deleted version will have the previous height and nil semantic version, indicating that the update was deleted.

Jump to

Keyboard shortcuts

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