blocks

package
v0.38.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: AGPL-3.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const BlockStoreLatestBlockMetaKey = "LatestBlockMeta"

Variables

This section is empty.

Functions

func NewBlockContext added in v0.38.0

func NewBlockContext(
	chainID flow.ChainID,
	height uint64,
	timestamp uint64,
	getHashByHeight func(uint64) gethCommon.Hash,
	prevRandao gethCommon.Hash,
	tracer *tracers.Tracer,
) (types.BlockContext, error)

NewBlockContext creates a new block context for the given chain ID and height. This is for use in offchain re-execution of transactions. It includes special casing for some historical block heights:

func ReconstructProposal added in v0.38.0

func ReconstructProposal(
	blockEvent *events.BlockEventPayload,
	results []*types.Result,
) *types.BlockProposal

func UseBlockHashCorrection added in v0.38.0

func UseBlockHashCorrection(chainID flow.ChainID, evmHeightOfCurrentBlock uint64, queriedEVMHeight uint64) (gethCommon.Hash, bool)

UseBlockHashCorrection returns the block hash correction for the given chain ID, EVM height, and queried EVM height, and a boolean indicating whether the correction should be used.

Types

type BasicProvider added in v0.38.0

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

BasicProvider implements a ledger-backed basic block snapshot provider it assumes sequential progress on blocks and expects a a OnBlockReceived call before block execution and a follow up OnBlockExecuted call after block execution.

func NewBasicProvider added in v0.38.0

func NewBasicProvider(
	chainID flow.ChainID,
	storage types.BackendStorage,
	rootAddr flow.Address,
) (*BasicProvider, error)

func (*BasicProvider) GetSnapshotAt added in v0.38.0

func (p *BasicProvider) GetSnapshotAt(height uint64) (
	types.BlockSnapshot,
	error,
)

GetSnapshotAt returns a block snapshot at the given height Snapshot at a height is not available until `OnBlockReceived` is called for that height.

func (*BasicProvider) OnBlockExecuted added in v0.38.0

func (p *BasicProvider) OnBlockExecuted(
	height uint64,
	resCol types.ReplayResultCollector,
	blockProposal *types.BlockProposal,
) error

OnBlockExecuted should be called after executing blocks.

func (*BasicProvider) OnBlockReceived added in v0.38.0

func (p *BasicProvider) OnBlockReceived(blockEvent *events.BlockEventPayload) error

OnBlockReceived should be called before executing blocks.

type Blocks

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

Blocks facilitates access to the recent block hash values and also the latest executed block meta data

func NewBlocks

func NewBlocks(
	chainID flow.ChainID,
	rootAddress flow.Address,
	storage types.BackendStorage,
) (*Blocks, error)

NewBlocks constructs a new blocks type

func (*Blocks) BlockContext added in v0.38.0

func (b *Blocks) BlockContext() (types.BlockContext, error)

BlockContext constructs a block context for the latest block

func (*Blocks) BlockHash

func (b *Blocks) BlockHash(height uint64) (gethCommon.Hash, error)

BlockHash returns the block hash for the given height

func (*Blocks) LatestBlock

func (b *Blocks) LatestBlock() (*Meta, error)

func (*Blocks) PushBlockHash

func (b *Blocks) PushBlockHash(
	height uint64,
	hash gethCommon.Hash,
) error

PushBlockHash pushes a new block block hash into the storage

func (*Blocks) PushBlockMeta

func (b *Blocks) PushBlockMeta(
	meta *Meta,
) error

PushBlock pushes a new block into the storage

type Meta

type Meta struct {
	Height    uint64
	Timestamp uint64
	Random    gethCommon.Hash
}

Meta holds meta data about a block

func MetaFromEncoded

func MetaFromEncoded(data []byte) (*Meta, error)

MetaFromEncoded constructs a Meta from encoded data

func NewMeta

func NewMeta(
	height uint64,
	timestamp uint64,
	random gethCommon.Hash,
) *Meta

NewBlockMeta constructs a new block meta

func (*Meta) Encode

func (bm *Meta) Encode() []byte

Encode encodes a meta

Jump to

Keyboard shortcuts

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