state

package
v1.7.16-rc.17 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: BSD-3-Clause Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockState

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

func NewBlockState

func NewBlockState(db database.Database) BlockState

func NewMeteredBlockState

func NewMeteredBlockState(db database.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 database.Database) ChainState

type HeightIndex added in v1.7.5

type HeightIndex interface {
	HeightIndexWriter
	HeightIndexGetter
	HeightIndexBatchSupport

	// ResetHeightIndex deletes all index DB entries
	ResetHeightIndex(logging.Logger, versiondb.Commitable) error
}

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

func NewHeightIndex added in v1.7.5

func NewHeightIndex(db database.Database, commitable versiondb.Commitable) HeightIndex

type HeightIndexBatchSupport added in v1.7.5

type HeightIndexBatchSupport interface {
	versiondb.Commitable

	GetCheckpoint() (ids.ID, error)
	SetCheckpoint(blkID ids.ID) error
	DeleteCheckpoint() error
}

A checkpoint is the blockID of the next block to be considered for height indexing. We store checkpoints to be able to duly resume long-running re-indexing ops.

type HeightIndexGetter added in v1.7.5

type HeightIndexGetter interface {
	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)
	IsIndexEmpty() (bool, error)
	HasIndexReset() (bool, error)
}

type HeightIndexWriter added in v1.7.5

type HeightIndexWriter interface {
	SetBlockIDAtHeight(height uint64, blkID ids.ID) error
	SetForkHeight(height uint64) error
	SetIndexHasReset() 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