tracker

package
v0.41.1-data-migration... Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTracker

type BaseTracker interface {
	// GetStartHeightFromBlockID returns the start height based on the provided starting block ID.
	// If the start block is the root block, skip it and begin from the next block.
	//
	// Parameters:
	// - startBlockID: The identifier of the starting block.
	//
	// Returns:
	// - uint64: The start height associated with the provided block ID.
	// - error: An error indicating any issues with retrieving the start height.
	//
	// Expected errors during normal operation:
	// - codes.NotFound - if the block was not found in storage
	// - codes.Internal - for any other error
	GetStartHeightFromBlockID(flow.Identifier) (uint64, error)

	// GetStartHeightFromHeight returns the start height based on the provided starting block height.
	// If the start block is the root block, skip it and begin from the next block.
	//
	// Parameters:
	// - startHeight: The height of the starting block.
	//
	// Returns:
	// - uint64: The start height associated with the provided block height.
	// - error: An error indicating any issues with retrieving the start height.
	//
	// Expected errors during normal operation:
	// - codes.InvalidArgument   - if the start height is less than the root block height.
	// - codes.NotFound  - if the header was not found in storage.
	GetStartHeightFromHeight(uint64) (uint64, error)

	// GetStartHeightFromLatest returns the start height based on the latest sealed block.
	// If the start block is the root block, skip it and begin from the next block.
	//
	// Parameters:
	// - ctx: Context for the operation.
	//
	// No errors are expected during normal operation.
	GetStartHeightFromLatest(context.Context) (uint64, error)
}

BaseTracker is an interface for a tracker that provides base GetStartHeight method related to both blocks and execution data tracking.

type BaseTrackerImpl

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

BaseTrackerImpl is an implementation of the BaseTracker interface.

func NewBaseTrackerImpl

func NewBaseTrackerImpl(
	rootBlockHeight uint64,
	state protocol.State,
	headers storage.Headers,
) *BaseTrackerImpl

NewBaseTrackerImpl creates a new instance of BaseTrackerImpl.

Parameters: - rootBlockHeight: The root block height, which serves as the baseline for calculating the start height. - state: The protocol state used for retrieving block information. - headers: The storage headers for accessing block headers.

Returns: - *BaseTrackerImpl: A new instance of BaseTrackerImpl.

func (*BaseTrackerImpl) GetStartHeightFromBlockID

func (b *BaseTrackerImpl) GetStartHeightFromBlockID(startBlockID flow.Identifier) (uint64, error)

GetStartHeightFromBlockID returns the start height based on the provided starting block ID. If the start block is the root block, skip it and begin from the next block.

Parameters: - startBlockID: The identifier of the starting block.

Returns: - uint64: The start height associated with the provided block ID. - error: An error indicating any issues with retrieving the start height.

Expected errors during normal operation: - codes.NotFound - if the block was not found in storage - codes.Internal - for any other error

func (*BaseTrackerImpl) GetStartHeightFromHeight

func (b *BaseTrackerImpl) GetStartHeightFromHeight(startHeight uint64) (uint64, error)

GetStartHeightFromHeight returns the start height based on the provided starting block height. If the start block is the root block, skip it and begin from the next block.

Parameters: - startHeight: The height of the starting block.

Returns: - uint64: The start height associated with the provided block height. - error: An error indicating any issues with retrieving the start height.

Expected errors during normal operation: - codes.InvalidArgument - if the start height is less than the root block height. - codes.NotFound - if the header was not found in storage.

func (*BaseTrackerImpl) GetStartHeightFromLatest

func (b *BaseTrackerImpl) GetStartHeightFromLatest(ctx context.Context) (uint64, error)

GetStartHeightFromLatest returns the start height based on the latest sealed block. If the start block is the root block, skip it and begin from the next block.

Parameters: - ctx: Context for the operation.

No errors are expected during normal operation.

type BlockTracker

type BlockTracker interface {
	BaseTracker

	// GetHighestHeight returns the highest height based on the specified block status which could be only BlockStatusSealed
	// or BlockStatusFinalized.
	// No errors are expected during normal operation.
	GetHighestHeight(flow.BlockStatus) (uint64, error)

	// ProcessOnFinalizedBlock drives the subscription logic when a block is finalized.
	// The input to this callback is treated as trusted. This method should be executed on
	// `OnFinalizedBlock` notifications from the node-internal consensus instance.
	// No errors are expected during normal operation.
	ProcessOnFinalizedBlock() error
}

BlockTracker is an interface for tracking blocks and handling block-related operations.

type BlockTrackerImpl

type BlockTrackerImpl struct {
	BaseTracker
	// contains filtered or unexported fields
}

BlockTrackerImpl is an implementation of the BlockTracker interface.

func NewBlockTracker

func NewBlockTracker(
	state protocol.State,
	rootHeight uint64,
	headers storage.Headers,
	broadcaster *engine.Broadcaster,
) (*BlockTrackerImpl, error)

NewBlockTracker creates a new BlockTrackerImpl instance.

Parameters: - state: The protocol state used for retrieving block information. - rootHeight: The root block height, serving as the baseline for calculating the start height. - headers: The storage headers for accessing block headers. - broadcaster: The engine broadcaster for publishing notifications.

No errors are expected during normal operation.

func (*BlockTrackerImpl) GetHighestHeight

func (b *BlockTrackerImpl) GetHighestHeight(blockStatus flow.BlockStatus) (uint64, error)

GetHighestHeight returns the highest height based on the specified block status.

Parameters: - blockStatus: The status of the block. It is expected that blockStatus has already been handled for invalid flow.BlockStatusUnknown.

Expected errors during normal operation: - codes.InvalidArgument - if block status is flow.BlockStatusUnknown.

func (*BlockTrackerImpl) ProcessOnFinalizedBlock

func (b *BlockTrackerImpl) ProcessOnFinalizedBlock() error

ProcessOnFinalizedBlock drives the subscription logic when a block is finalized. The input to this callback is treated as trusted. This method should be executed on `OnFinalizedBlock` notifications from the node-internal consensus instance. No errors are expected during normal operation. Any errors encountered should be treated as an exception.

type ExecutionDataTracker

type ExecutionDataTracker interface {
	BaseTracker

	// GetStartHeight returns the start height to use when searching.
	// Only one of startBlockID and startHeight may be set. Otherwise, an InvalidArgument error is returned.
	// If a block is provided and does not exist, a NotFound error is returned.
	// If neither startBlockID nor startHeight is provided, the latest sealed block is used.
	// If the start block is the root block, skip it and begin from the next block.
	//
	// Parameters:
	// - ctx: Context for the operation.
	// - startBlockID: The identifier of the starting block. If provided, startHeight should be 0.
	// - startHeight: The height of the starting block. If provided, startBlockID should be flow.ZeroID.
	//
	// Returns:
	// - uint64: The start height for searching.
	// - error: An error indicating the result of the operation, if any.
	//
	// Expected errors during normal operation:
	// - codes.InvalidArgument - if both startBlockID and startHeight are provided, if the start height is less than the root block height,
	// if the start height is out of bounds based on indexed heights (when index is used).
	// - codes.NotFound   - if a block is provided and does not exist.
	// - codes.Internal        - if there is an internal error.
	GetStartHeight(context.Context, flow.Identifier, uint64) (uint64, error)

	// GetHighestHeight returns the highest height that we have consecutive execution data for.
	GetHighestHeight() uint64

	// OnExecutionData is used to notify the tracker when a new execution data is received.
	OnExecutionData(*execution_data.BlockExecutionDataEntity)
}

ExecutionDataTracker is an interface for tracking the highest consecutive block height for which we have received a new Execution Data notification

type ExecutionDataTrackerImpl

type ExecutionDataTrackerImpl struct {
	BaseTracker
	// contains filtered or unexported fields
}

ExecutionDataTrackerImpl is an implementation of the ExecutionDataTracker interface.

func NewExecutionDataTracker

func NewExecutionDataTracker(
	log zerolog.Logger,
	state protocol.State,
	rootHeight uint64,
	headers storage.Headers,
	broadcaster *engine.Broadcaster,
	highestAvailableFinalizedHeight uint64,
	indexReporter state_synchronization.IndexReporter,
	useIndex bool,
) *ExecutionDataTrackerImpl

NewExecutionDataTracker creates a new ExecutionDataTrackerImpl instance.

Parameters: - log: The logger to use for logging. - state: The protocol state used for retrieving block information. - rootHeight: The root block height, serving as the baseline for calculating the start height. - headers: The storage headers for accessing block headers. - broadcaster: The engine broadcaster for publishing notifications. - highestAvailableFinalizedHeight: The highest available finalized block height. - indexReporter: The index reporter for checking indexed block heights. - useIndex: A flag indicating whether to use indexed block heights for validation.

Returns: - *ExecutionDataTrackerImpl: A new instance of ExecutionDataTrackerImpl.

func (*ExecutionDataTrackerImpl) GetHighestHeight

func (e *ExecutionDataTrackerImpl) GetHighestHeight() uint64

GetHighestHeight returns the highest height that we have consecutive execution data for.

func (*ExecutionDataTrackerImpl) GetStartHeight

func (e *ExecutionDataTrackerImpl) GetStartHeight(ctx context.Context, startBlockID flow.Identifier, startHeight uint64) (uint64, error)

GetStartHeight returns the start height to use when searching. Only one of startBlockID and startHeight may be set. Otherwise, an InvalidArgument error is returned. If a block is provided and does not exist, a NotFound error is returned. If neither startBlockID nor startHeight is provided, the latest sealed block is used. If the start block is the root block, skip it and begin from the next block.

Parameters: - ctx: Context for the operation. - startBlockID: The identifier of the starting block. If provided, startHeight should be 0. - startHeight: The height of the starting block. If provided, startBlockID should be flow.ZeroID.

Returns: - uint64: The start height for searching. - error: An error indicating the result of the operation, if any.

Expected errors during normal operation: - codes.InvalidArgument - if both startBlockID and startHeight are provided, if the start height is less than the root block height, if the start height is out of bounds based on indexed heights (when index is used). - codes.NotFound - if a block is provided and does not exist. - codes.Internal - if there is an internal error.

func (*ExecutionDataTrackerImpl) GetStartHeightFromBlockID

func (e *ExecutionDataTrackerImpl) GetStartHeightFromBlockID(startBlockID flow.Identifier) (uint64, error)

GetStartHeightFromBlockID returns the start height based on the provided starting block ID.

Parameters: - startBlockID: The identifier of the starting block.

Returns: - uint64: The start height associated with the provided block ID. - error: An error indicating any issues with retrieving the start height.

Expected errors during normal operation: - codes.NotFound - if the block was not found in storage - codes.InvalidArgument - if the start height is out of bounds based on indexed heights. - codes.FailedPrecondition - if the index reporter is not ready yet. - codes.Internal - for any other error during validation.

func (*ExecutionDataTrackerImpl) GetStartHeightFromHeight

func (e *ExecutionDataTrackerImpl) GetStartHeightFromHeight(startHeight uint64) (uint64, error)

GetStartHeightFromHeight returns the start height based on the provided starting block height.

Parameters: - startHeight: The height of the starting block.

Returns: - uint64: The start height associated with the provided block height. - error: An error indicating any issues with retrieving the start height.

Expected errors during normal operation: - codes.InvalidArgument - if the start height is less than the root block height, if the start height is out of bounds based on indexed heights - codes.NotFound - if the header was not found in storage. - codes.FailedPrecondition - if the index reporter is not ready yet. - codes.Internal - for any other error during validation.

func (*ExecutionDataTrackerImpl) GetStartHeightFromLatest

func (e *ExecutionDataTrackerImpl) GetStartHeightFromLatest(ctx context.Context) (uint64, error)

GetStartHeightFromLatest returns the start height based on the latest sealed block.

Parameters: - ctx: Context for the operation.

Expected errors during normal operation: - codes.InvalidArgument - if the start height is out of bounds based on indexed heights. - codes.FailedPrecondition - if the index reporter is not ready yet. - codes.Internal - for any other error during validation.

func (*ExecutionDataTrackerImpl) OnExecutionData

func (e *ExecutionDataTrackerImpl) OnExecutionData(executionData *execution_data.BlockExecutionDataEntity)

OnExecutionData is used to notify the tracker when a new execution data is received.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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