state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

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

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

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

type HeightIndexBatchSupport

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

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

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