state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0, BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const OriginStateHashBase58 = "96yCdioNdifMb8xTeHQVQ8BzDnXDbRBoYzTq7iVaymvV"

Variables

This section is empty.

Functions

func LoadBlockBytes added in v0.2.0

func LoadBlockBytes(store kvstore.KVStore, stateIndex uint32) ([]byte, error)

LoadBlockBytes loads block bytes of the specified block index from DB

func NewStateUpdate

func NewStateUpdate(timestamp ...time.Time) *stateUpdateImpl

NewStateUpdate creates a state update with timestamp mutation, if provided

func OriginStateHash added in v0.2.0

func OriginStateHash() hashing.HashValue

Types

type Block added in v0.1.0

type Block interface {
	BlockIndex() uint32
	ApprovingOutputID() ledgerstate.OutputID
	SetApprovingOutputID(ledgerstate.OutputID)
	Timestamp() time.Time
	PreviousStateHash() hashing.HashValue
	EssenceBytes() []byte // except state transaction id
	Bytes() []byte
}

Block is a sequence of state updates applicable to the virtual state

func BlockFromBytes added in v0.2.0

func BlockFromBytes(data []byte) (Block, error)

func LoadBlock added in v0.1.0

func LoadBlock(store kvstore.KVStore, stateIndex uint32) (Block, error)

LoadBlock loads block from DB and decodes it

type OptimisticStateReader added in v0.2.0

type OptimisticStateReader interface {
	BlockIndex() (uint32, error)
	Timestamp() (time.Time, error)
	Hash() (hashing.HashValue, error)
	KVStoreReader() kv.KVStoreReader
	SetBaseline()
}

type OptimisticStateReaderImpl added in v0.2.0

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

state reader reads the chain state from db and validates it

func NewOptimisticStateReader added in v0.2.0

func NewOptimisticStateReader(db kvstore.KVStore, glb coreutil.ChainStateSync) *OptimisticStateReaderImpl

NewOptimisticStateReader creates new optimistic read-only access to the database. It contains own read baseline

func (*OptimisticStateReaderImpl) BlockIndex added in v0.2.0

func (r *OptimisticStateReaderImpl) BlockIndex() (uint32, error)

func (*OptimisticStateReaderImpl) Hash added in v0.2.0

func (*OptimisticStateReaderImpl) KVStoreReader added in v0.2.0

func (r *OptimisticStateReaderImpl) KVStoreReader() kv.KVStoreReader

func (*OptimisticStateReaderImpl) SetBaseline added in v0.2.0

func (r *OptimisticStateReaderImpl) SetBaseline()

func (*OptimisticStateReaderImpl) Timestamp added in v0.2.0

func (r *OptimisticStateReaderImpl) Timestamp() (time.Time, error)

type StateUpdate

type StateUpdate interface {
	Mutations() *buffered.Mutations
	Clone() StateUpdate
	Bytes() []byte
	String() string
}

StateUpdate is a set of mutations

func NewStateUpdateWithBlocklogValues added in v0.2.0

func NewStateUpdateWithBlocklogValues(blockIndex uint32, timestamp time.Time, prevStateHash hashing.HashValue) StateUpdate

type VirtualStateAccess added in v0.2.0

type VirtualStateAccess interface {
	BlockIndex() uint32
	Timestamp() time.Time
	PreviousStateHash() hashing.HashValue
	StateCommitment() hashing.HashValue
	KVStoreReader() kv.KVStoreReader
	ApplyStateUpdates(...StateUpdate)
	ApplyBlock(Block) error
	ExtractBlock() (Block, error)
	Commit(blocks ...Block) error
	KVStore() *buffered.BufferedKVStoreAccess
	Copy() VirtualStateAccess
	DangerouslyConvertToString() string
}

VirtualStateAccess is a virtualized access interface to the chain's database It consists of state reader and the buffer to collect mutations to key values

func CreateOriginState added in v0.2.0

func CreateOriginState(store kvstore.KVStore, chainID *iscp.ChainID) (VirtualStateAccess, error)

CreateOriginState creates zero state which is the minimal consistent state. It is not committed it is an origin state. It has statically known hash coreutils.OriginStateHashBase58

func LoadSolidState

func LoadSolidState(store kvstore.KVStore, chainID *iscp.ChainID) (VirtualStateAccess, bool, error)

LoadSolidState establishes VirtualStateAccess interface with the solid state in DB. Checks consistency of DB

func WrapMustOptimisticVirtualStateAccess added in v0.2.0

func WrapMustOptimisticVirtualStateAccess(state VirtualStateAccess, baseline coreutil.StateBaseline) VirtualStateAccess

WrapMustOptimisticVirtualStateAccess wraps virtual state with state baseline in on object Does not copy buffers

Jump to

Keyboard shortcuts

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