states

package
v1.9.10-rc.6 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingParentState = errors.New("missing parent state")
)

Functions

This section is empty.

Types

type Chain added in v1.9.8

type Chain interface {
	avax.UTXOGetter
	avax.UTXOAdder
	avax.UTXODeleter

	GetTx(txID ids.ID) (*txs.Tx, error)
	AddTx(tx *txs.Tx)

	GetBlockID(height uint64) (ids.ID, error)
	GetBlock(blkID ids.ID) (blocks.Block, error)
	AddBlock(block blocks.Block)

	GetLastAccepted() ids.ID
	SetLastAccepted(blkID ids.ID)

	GetTimestamp() time.Time
	SetTimestamp(t time.Time)
}

type Diff added in v1.9.8

type Diff interface {
	Chain

	Apply(Chain)
}

func NewDiff added in v1.9.8

func NewDiff(
	parentID ids.ID,
	stateVersions Versions,
) (Diff, error)

type State

type State interface {
	Chain
	avax.UTXOReader

	IsInitialized() (bool, error)
	SetInitialized() error

	// InitializeChainState is called after the VM has been linearized. Calling
	// [GetLastAccepted] or [GetTimestamp] before calling this function will
	// return uninitialized data.
	//
	// Invariant: After the chain is linearized, this function is expected to be
	// called during startup.
	InitializeChainState(stopVertexID ids.ID, genesisTimestamp time.Time) error

	// TODO: deprecate statuses. We should only persist accepted state
	// Status returns a status from storage.
	GetStatus(id ids.ID) (choices.Status, error)
	// AddStatus saves a status in storage.
	AddStatus(id ids.ID, status choices.Status)

	// Discard uncommitted changes to the database.
	Abort()

	// Commit changes to the base database.
	Commit() error

	// Returns a batch of unwritten changes that, when written, will commit all
	// pending changes to the base database.
	CommitBatch() (database.Batch, error)

	Close() error
}

State persistently maintains a set of UTXOs, transaction, statuses, and singletons.

func New

func New(
	db *versiondb.Database,
	parser blocks.Parser,
	metrics prometheus.Registerer,
) (State, error)

type Versions added in v1.9.8

type Versions interface {
	// GetState returns the state of the chain after [blkID] has been accepted.
	// If the state is not known, `false` will be returned.
	GetState(blkID ids.ID) (Chain, bool)
}

Jump to

Keyboard shortcuts

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