blocks

package
v0.38.0-preview.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BlockStoreLatestBlockMetaKey = "LatestBlockMeta"

Variables

This section is empty.

Functions

func NewBlockContext

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

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

func UseBlockHashCorrection

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

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

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

func (*BasicProvider) GetSnapshotAt

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

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

OnBlockExecuted should be called after executing blocks.

func (*BasicProvider) OnBlockReceived

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

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