state

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const CodecVersion = 0

Variables

Functions

This section is empty.

Types

type BlockState

type BlockState interface {
	GetBlock(blkID ids.ID) (block.Block, error)
	PutBlock(blk block.Block) error
	DeleteBlock(blkID ids.ID) error
}

func NewBlockState

func NewBlockState(db db.Database) BlockState

func NewMeteredBlockState

func NewMeteredBlockState(db db.Database, namespace string, metrics prometheus.Registerer) (BlockState, error)

type ChainState

type ChainState interface {
	SetLastAccepted(blkID ids.ID) error
	DeleteLastAccepted() error
	GetLastAccepted() (ids.ID, error)
}

func NewChainState

func NewChainState(db db.Database) ChainState

type HeightIndex

type HeightIndex interface {
	HeightIndexWriter
	HeightIndexGetter
}

HeightIndex contains mapping of blockHeights to accepted proposer block IDs along with some metadata (fork height and checkpoint).

func NewHeightIndex

func NewHeightIndex(database db.Database, _ *versiondb.Database) HeightIndex

type HeightIndexGetter

type HeightIndexGetter interface {
	// GetMinimumHeight return the smallest height of an indexed blockID. If
	// there are no indexed blockIDs, ErrNotFound will be returned.
	GetMinimumHeight() (uint64, error)
	GetBlockIDAtHeight(height uint64) (ids.ID, error)

	// Fork height is stored when the first post-fork block/option is accepted.
	// Before that, fork height won't be found.
	GetForkHeight() (uint64, error)
}

type HeightIndexWriter

type HeightIndexWriter interface {
	SetForkHeight(height uint64) error
	SetBlockIDAtHeight(height uint64, blkID ids.ID) error
	DeleteBlockIDAtHeight(height uint64) error
}

type State

type State interface {
	ChainState
	BlockState
	HeightIndex
}

func New

func New(db *versiondb.Database) State

func NewMetered

func NewMetered(db *versiondb.Database, namespace string, metrics prometheus.Registerer) (State, error)

Jump to

Keyboard shortcuts

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