state

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: Apache-2.0, BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger()

func IsRequestCompleted

func IsRequestCompleted(addr *address.Address, reqid *sctransaction.RequestId) (bool, error)

func LoadSolidState

func LoadSolidState(scAddress *address.Address) (VirtualState, Batch, bool, error)

func NewEmptyVirtualState

func NewEmptyVirtualState(scAddress *address.Address) *virtualState

func NewVirtualState

func NewVirtualState(db kvstore.KVStore, scAddress *address.Address) *virtualState

Types

type Batch

type Batch interface {
	ForEach(func(uint16, StateUpdate) bool)
	StateIndex() uint32
	WithStateIndex(uint32) Batch
	StateTransactionId() valuetransaction.ID
	WithStateTransaction(valuetransaction.ID) Batch
	Timestamp() int64
	Size() uint16
	RequestIds() []*sctransaction.RequestId
	EssenceHash() *hashing.HashValue // except state transaction id
	String() string
	Write(io.Writer) error
	Read(io.Reader) error
}

ResultBatch of state updates applicable to the variable state by applying state updates in a sequence defined by batch indices

func BatchFromBytes

func BatchFromBytes(data []byte) (Batch, error)

func LoadBatch

func LoadBatch(addr *address.Address, stateIndex uint32) (Batch, error)

func MustNewOriginBatch

func MustNewOriginBatch(color *balance.Color) Batch

batch with empty state update and nil state hash

func NewBatch

func NewBatch(stateUpdates []StateUpdate) (Batch, error)

validates, enumerates and creates a batch from array of state updates

type StateUpdate

type StateUpdate interface {
	// request which resulted in this state update
	RequestId() *sctransaction.RequestId
	Timestamp() int64
	WithTimestamp(int64) StateUpdate
	// the payload of variables/values
	String() string
	Mutations() kv.MutationSequence
	Clear()
	Write(io.Writer) error
	Read(io.Reader) error
}

AccessState update represents update to the variable state it is calculated by the VM (in batches) AccessState updates comes in batches, all state updates within one batch has same state index, state tx id and batch size. ResultBatch index is unique in batch ResultBatch is completed when it contains one state update for each index

func NewStateUpdate

func NewStateUpdate(reqid *sctransaction.RequestId) StateUpdate

func NewStateUpdateRead

func NewStateUpdateRead(r io.Reader) (StateUpdate, error)

type VirtualState

type VirtualState interface {
	// index of the current state. AccessState index is incremented when state transition occurs
	// index 0 means origin state
	StateIndex() uint32
	ApplyStateIndex(uint32)
	// check if state contains record with the given owner address
	InitiatedBy(*address.Address) bool
	// timestamp
	Timestamp() int64
	// updates state without changing state index
	ApplyStateUpdate(stateUpd StateUpdate)
	// applies batch of state updates, state index and timestamp
	ApplyBatch(Batch) error
	// commit means saving virtual state to sc db, making it persistent (solid)
	CommitToDb(batch Batch) error
	// return hash of the variable state. It is a root of the Merkle chain of all
	// state updates starting from the origin
	Hash() *hashing.HashValue
	// the storage of variable/value pairs
	Variables() kv.BufferedKVStore
	Clone() VirtualState
	DangerouslyConvertToString() string
}

represents an interface to the mutable state of the smart contract

Jump to

Keyboard shortcuts

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