Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package state is a generated GoMock package.

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Chain

type Chain interface {
	ReadOnlyChain
	lux.UTXOAdder
	lux.UTXODeleter

	AddTx(tx *txs.Tx)
	AddBlock(block block.Block)
	SetLastAccepted(blkID ids.ID)
	SetTimestamp(t time.Time)
}

type Diff

type Diff interface {
	Chain

	Apply(Chain)
}

func NewDiff

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

func NewDiffOn

func NewDiffOn(parentState Chain) (Diff, error)

type MockChain

type MockChain struct {
	// contains filtered or unexported fields
}

MockChain is a mock of Chain interface.

func NewMockChain

func NewMockChain(ctrl *gomock.Controller) *MockChain

NewMockChain creates a new mock instance.

func (*MockChain) AddBlock

func (m *MockChain) AddBlock(arg0 block.Block)

AddBlock mocks base method.

func (*MockChain) AddTx

func (m *MockChain) AddTx(arg0 *txs.Tx)

AddTx mocks base method.

func (*MockChain) AddUTXO

func (m *MockChain) AddUTXO(arg0 *lux.UTXO)

AddUTXO mocks base method.

func (*MockChain) DeleteUTXO

func (m *MockChain) DeleteUTXO(arg0 ids.ID)

DeleteUTXO mocks base method.

func (*MockChain) EXPECT

func (m *MockChain) EXPECT() *MockChainMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockChain) GetBlock

func (m *MockChain) GetBlock(arg0 ids.ID) (block.Block, error)

GetBlock mocks base method.

func (*MockChain) GetBlockIDAtHeight

func (m *MockChain) GetBlockIDAtHeight(arg0 uint64) (ids.ID, error)

GetBlockIDAtHeight mocks base method.

func (*MockChain) GetLastAccepted

func (m *MockChain) GetLastAccepted() ids.ID

GetLastAccepted mocks base method.

func (*MockChain) GetTimestamp

func (m *MockChain) GetTimestamp() time.Time

GetTimestamp mocks base method.

func (*MockChain) GetTx

func (m *MockChain) GetTx(arg0 ids.ID) (*txs.Tx, error)

GetTx mocks base method.

func (*MockChain) GetUTXO

func (m *MockChain) GetUTXO(arg0 ids.ID) (*lux.UTXO, error)

GetUTXO mocks base method.

func (*MockChain) SetLastAccepted

func (m *MockChain) SetLastAccepted(arg0 ids.ID)

SetLastAccepted mocks base method.

func (*MockChain) SetTimestamp

func (m *MockChain) SetTimestamp(arg0 time.Time)

SetTimestamp mocks base method.

type MockChainMockRecorder

type MockChainMockRecorder struct {
	// contains filtered or unexported fields
}

MockChainMockRecorder is the mock recorder for MockChain.

func (*MockChainMockRecorder) AddBlock

func (mr *MockChainMockRecorder) AddBlock(arg0 any) *gomock.Call

AddBlock indicates an expected call of AddBlock.

func (*MockChainMockRecorder) AddTx

func (mr *MockChainMockRecorder) AddTx(arg0 any) *gomock.Call

AddTx indicates an expected call of AddTx.

func (*MockChainMockRecorder) AddUTXO

func (mr *MockChainMockRecorder) AddUTXO(arg0 any) *gomock.Call

AddUTXO indicates an expected call of AddUTXO.

func (*MockChainMockRecorder) DeleteUTXO

func (mr *MockChainMockRecorder) DeleteUTXO(arg0 any) *gomock.Call

DeleteUTXO indicates an expected call of DeleteUTXO.

func (*MockChainMockRecorder) GetBlock

func (mr *MockChainMockRecorder) GetBlock(arg0 any) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockChainMockRecorder) GetBlockIDAtHeight

func (mr *MockChainMockRecorder) GetBlockIDAtHeight(arg0 any) *gomock.Call

GetBlockIDAtHeight indicates an expected call of GetBlockIDAtHeight.

func (*MockChainMockRecorder) GetLastAccepted

func (mr *MockChainMockRecorder) GetLastAccepted() *gomock.Call

GetLastAccepted indicates an expected call of GetLastAccepted.

func (*MockChainMockRecorder) GetTimestamp

func (mr *MockChainMockRecorder) GetTimestamp() *gomock.Call

GetTimestamp indicates an expected call of GetTimestamp.

func (*MockChainMockRecorder) GetTx

func (mr *MockChainMockRecorder) GetTx(arg0 any) *gomock.Call

GetTx indicates an expected call of GetTx.

func (*MockChainMockRecorder) GetUTXO

func (mr *MockChainMockRecorder) GetUTXO(arg0 any) *gomock.Call

GetUTXO indicates an expected call of GetUTXO.

func (*MockChainMockRecorder) SetLastAccepted

func (mr *MockChainMockRecorder) SetLastAccepted(arg0 any) *gomock.Call

SetLastAccepted indicates an expected call of SetLastAccepted.

func (*MockChainMockRecorder) SetTimestamp

func (mr *MockChainMockRecorder) SetTimestamp(arg0 any) *gomock.Call

SetTimestamp indicates an expected call of SetTimestamp.

type MockDiff

type MockDiff struct {
	// contains filtered or unexported fields
}

MockDiff is a mock of Diff interface.

func NewMockDiff

func NewMockDiff(ctrl *gomock.Controller) *MockDiff

NewMockDiff creates a new mock instance.

func (*MockDiff) AddBlock

func (m *MockDiff) AddBlock(arg0 block.Block)

AddBlock mocks base method.

func (*MockDiff) AddTx

func (m *MockDiff) AddTx(arg0 *txs.Tx)

AddTx mocks base method.

func (*MockDiff) AddUTXO

func (m *MockDiff) AddUTXO(arg0 *lux.UTXO)

AddUTXO mocks base method.

func (*MockDiff) Apply

func (m *MockDiff) Apply(arg0 Chain)

Apply mocks base method.

func (*MockDiff) DeleteUTXO

func (m *MockDiff) DeleteUTXO(arg0 ids.ID)

DeleteUTXO mocks base method.

func (*MockDiff) EXPECT

func (m *MockDiff) EXPECT() *MockDiffMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDiff) GetBlock

func (m *MockDiff) GetBlock(arg0 ids.ID) (block.Block, error)

GetBlock mocks base method.

func (*MockDiff) GetBlockIDAtHeight

func (m *MockDiff) GetBlockIDAtHeight(arg0 uint64) (ids.ID, error)

GetBlockIDAtHeight mocks base method.

func (*MockDiff) GetLastAccepted

func (m *MockDiff) GetLastAccepted() ids.ID

GetLastAccepted mocks base method.

func (*MockDiff) GetTimestamp

func (m *MockDiff) GetTimestamp() time.Time

GetTimestamp mocks base method.

func (*MockDiff) GetTx

func (m *MockDiff) GetTx(arg0 ids.ID) (*txs.Tx, error)

GetTx mocks base method.

func (*MockDiff) GetUTXO

func (m *MockDiff) GetUTXO(arg0 ids.ID) (*lux.UTXO, error)

GetUTXO mocks base method.

func (*MockDiff) SetLastAccepted

func (m *MockDiff) SetLastAccepted(arg0 ids.ID)

SetLastAccepted mocks base method.

func (*MockDiff) SetTimestamp

func (m *MockDiff) SetTimestamp(arg0 time.Time)

SetTimestamp mocks base method.

type MockDiffMockRecorder

type MockDiffMockRecorder struct {
	// contains filtered or unexported fields
}

MockDiffMockRecorder is the mock recorder for MockDiff.

func (*MockDiffMockRecorder) AddBlock

func (mr *MockDiffMockRecorder) AddBlock(arg0 any) *gomock.Call

AddBlock indicates an expected call of AddBlock.

func (*MockDiffMockRecorder) AddTx

func (mr *MockDiffMockRecorder) AddTx(arg0 any) *gomock.Call

AddTx indicates an expected call of AddTx.

func (*MockDiffMockRecorder) AddUTXO

func (mr *MockDiffMockRecorder) AddUTXO(arg0 any) *gomock.Call

AddUTXO indicates an expected call of AddUTXO.

func (*MockDiffMockRecorder) Apply

func (mr *MockDiffMockRecorder) Apply(arg0 any) *gomock.Call

Apply indicates an expected call of Apply.

func (*MockDiffMockRecorder) DeleteUTXO

func (mr *MockDiffMockRecorder) DeleteUTXO(arg0 any) *gomock.Call

DeleteUTXO indicates an expected call of DeleteUTXO.

func (*MockDiffMockRecorder) GetBlock

func (mr *MockDiffMockRecorder) GetBlock(arg0 any) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockDiffMockRecorder) GetBlockIDAtHeight

func (mr *MockDiffMockRecorder) GetBlockIDAtHeight(arg0 any) *gomock.Call

GetBlockIDAtHeight indicates an expected call of GetBlockIDAtHeight.

func (*MockDiffMockRecorder) GetLastAccepted

func (mr *MockDiffMockRecorder) GetLastAccepted() *gomock.Call

GetLastAccepted indicates an expected call of GetLastAccepted.

func (*MockDiffMockRecorder) GetTimestamp

func (mr *MockDiffMockRecorder) GetTimestamp() *gomock.Call

GetTimestamp indicates an expected call of GetTimestamp.

func (*MockDiffMockRecorder) GetTx

func (mr *MockDiffMockRecorder) GetTx(arg0 any) *gomock.Call

GetTx indicates an expected call of GetTx.

func (*MockDiffMockRecorder) GetUTXO

func (mr *MockDiffMockRecorder) GetUTXO(arg0 any) *gomock.Call

GetUTXO indicates an expected call of GetUTXO.

func (*MockDiffMockRecorder) SetLastAccepted

func (mr *MockDiffMockRecorder) SetLastAccepted(arg0 any) *gomock.Call

SetLastAccepted indicates an expected call of SetLastAccepted.

func (*MockDiffMockRecorder) SetTimestamp

func (mr *MockDiffMockRecorder) SetTimestamp(arg0 any) *gomock.Call

SetTimestamp indicates an expected call of SetTimestamp.

type MockState

type MockState struct {
	// contains filtered or unexported fields
}

MockState is a mock of State interface.

func NewMockState

func NewMockState(ctrl *gomock.Controller) *MockState

NewMockState creates a new mock instance.

func (*MockState) Abort

func (m *MockState) Abort()

Abort mocks base method.

func (*MockState) AddBlock

func (m *MockState) AddBlock(arg0 block.Block)

AddBlock mocks base method.

func (*MockState) AddTx

func (m *MockState) AddTx(arg0 *txs.Tx)

AddTx mocks base method.

func (*MockState) AddUTXO

func (m *MockState) AddUTXO(arg0 *lux.UTXO)

AddUTXO mocks base method.

func (*MockState) Checksums

func (m *MockState) Checksums() (ids.ID, ids.ID)

Checksums mocks base method.

func (*MockState) Close

func (m *MockState) Close() error

Close mocks base method.

func (*MockState) Commit

func (m *MockState) Commit() error

Commit mocks base method.

func (*MockState) CommitBatch

func (m *MockState) CommitBatch() (database.Batch, error)

CommitBatch mocks base method.

func (*MockState) DeleteUTXO

func (m *MockState) DeleteUTXO(arg0 ids.ID)

DeleteUTXO mocks base method.

func (*MockState) EXPECT

func (m *MockState) EXPECT() *MockStateMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockState) GetBlock

func (m *MockState) GetBlock(arg0 ids.ID) (block.Block, error)

GetBlock mocks base method.

func (*MockState) GetBlockIDAtHeight

func (m *MockState) GetBlockIDAtHeight(arg0 uint64) (ids.ID, error)

GetBlockIDAtHeight mocks base method.

func (*MockState) GetLastAccepted

func (m *MockState) GetLastAccepted() ids.ID

GetLastAccepted mocks base method.

func (*MockState) GetTimestamp

func (m *MockState) GetTimestamp() time.Time

GetTimestamp mocks base method.

func (*MockState) GetTx

func (m *MockState) GetTx(arg0 ids.ID) (*txs.Tx, error)

GetTx mocks base method.

func (*MockState) GetUTXO

func (m *MockState) GetUTXO(arg0 ids.ID) (*lux.UTXO, error)

GetUTXO mocks base method.

func (*MockState) InitializeChainState

func (m *MockState) InitializeChainState(arg0 ids.ID, arg1 time.Time) error

InitializeChainState mocks base method.

func (*MockState) IsInitialized

func (m *MockState) IsInitialized() (bool, error)

IsInitialized mocks base method.

func (*MockState) SetInitialized

func (m *MockState) SetInitialized() error

SetInitialized mocks base method.

func (*MockState) SetLastAccepted

func (m *MockState) SetLastAccepted(arg0 ids.ID)

SetLastAccepted mocks base method.

func (*MockState) SetTimestamp

func (m *MockState) SetTimestamp(arg0 time.Time)

SetTimestamp mocks base method.

func (*MockState) UTXOIDs

func (m *MockState) UTXOIDs(arg0 []byte, arg1 ids.ID, arg2 int) ([]ids.ID, error)

UTXOIDs mocks base method.

type MockStateMockRecorder

type MockStateMockRecorder struct {
	// contains filtered or unexported fields
}

MockStateMockRecorder is the mock recorder for MockState.

func (*MockStateMockRecorder) Abort

func (mr *MockStateMockRecorder) Abort() *gomock.Call

Abort indicates an expected call of Abort.

func (*MockStateMockRecorder) AddBlock

func (mr *MockStateMockRecorder) AddBlock(arg0 any) *gomock.Call

AddBlock indicates an expected call of AddBlock.

func (*MockStateMockRecorder) AddTx

func (mr *MockStateMockRecorder) AddTx(arg0 any) *gomock.Call

AddTx indicates an expected call of AddTx.

func (*MockStateMockRecorder) AddUTXO

func (mr *MockStateMockRecorder) AddUTXO(arg0 any) *gomock.Call

AddUTXO indicates an expected call of AddUTXO.

func (*MockStateMockRecorder) Checksums

func (mr *MockStateMockRecorder) Checksums() *gomock.Call

Checksums indicates an expected call of Checksums.

func (*MockStateMockRecorder) Close

func (mr *MockStateMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockStateMockRecorder) Commit

func (mr *MockStateMockRecorder) Commit() *gomock.Call

Commit indicates an expected call of Commit.

func (*MockStateMockRecorder) CommitBatch

func (mr *MockStateMockRecorder) CommitBatch() *gomock.Call

CommitBatch indicates an expected call of CommitBatch.

func (*MockStateMockRecorder) DeleteUTXO

func (mr *MockStateMockRecorder) DeleteUTXO(arg0 any) *gomock.Call

DeleteUTXO indicates an expected call of DeleteUTXO.

func (*MockStateMockRecorder) GetBlock

func (mr *MockStateMockRecorder) GetBlock(arg0 any) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockStateMockRecorder) GetBlockIDAtHeight

func (mr *MockStateMockRecorder) GetBlockIDAtHeight(arg0 any) *gomock.Call

GetBlockIDAtHeight indicates an expected call of GetBlockIDAtHeight.

func (*MockStateMockRecorder) GetLastAccepted

func (mr *MockStateMockRecorder) GetLastAccepted() *gomock.Call

GetLastAccepted indicates an expected call of GetLastAccepted.

func (*MockStateMockRecorder) GetTimestamp

func (mr *MockStateMockRecorder) GetTimestamp() *gomock.Call

GetTimestamp indicates an expected call of GetTimestamp.

func (*MockStateMockRecorder) GetTx

func (mr *MockStateMockRecorder) GetTx(arg0 any) *gomock.Call

GetTx indicates an expected call of GetTx.

func (*MockStateMockRecorder) GetUTXO

func (mr *MockStateMockRecorder) GetUTXO(arg0 any) *gomock.Call

GetUTXO indicates an expected call of GetUTXO.

func (*MockStateMockRecorder) InitializeChainState

func (mr *MockStateMockRecorder) InitializeChainState(arg0, arg1 any) *gomock.Call

InitializeChainState indicates an expected call of InitializeChainState.

func (*MockStateMockRecorder) IsInitialized

func (mr *MockStateMockRecorder) IsInitialized() *gomock.Call

IsInitialized indicates an expected call of IsInitialized.

func (*MockStateMockRecorder) SetInitialized

func (mr *MockStateMockRecorder) SetInitialized() *gomock.Call

SetInitialized indicates an expected call of SetInitialized.

func (*MockStateMockRecorder) SetLastAccepted

func (mr *MockStateMockRecorder) SetLastAccepted(arg0 any) *gomock.Call

SetLastAccepted indicates an expected call of SetLastAccepted.

func (*MockStateMockRecorder) SetTimestamp

func (mr *MockStateMockRecorder) SetTimestamp(arg0 any) *gomock.Call

SetTimestamp indicates an expected call of SetTimestamp.

func (*MockStateMockRecorder) UTXOIDs

func (mr *MockStateMockRecorder) UTXOIDs(arg0, arg1, arg2 any) *gomock.Call

UTXOIDs indicates an expected call of UTXOIDs.

type ReadOnlyChain

type ReadOnlyChain interface {
	lux.UTXOGetter

	GetTx(txID ids.ID) (*txs.Tx, error)
	GetBlockIDAtHeight(height uint64) (ids.ID, error)
	GetBlock(blkID ids.ID) (block.Block, error)
	GetLastAccepted() ids.ID
	GetTimestamp() time.Time
}

type State

type State interface {
	Chain
	lux.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

	// 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)

	// Checksum returns the current state checksum.
	Checksum() ids.ID

	Close() error
}

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

func New

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

type Versions

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)
}

Directories

Path Synopsis
Package statemock is a generated GoMock package.
Package statemock is a generated GoMock package.

Jump to

Keyboard shortcuts

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