state

package
v0.6.1-preview Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeRangeScanIterator

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

CompositeRangeScanIterator - an implementation of interface 'statemgmt.RangeScanIterator' This provides a wrapper on top of more than one underlying iterators

func (*CompositeRangeScanIterator) Close

func (itr *CompositeRangeScanIterator) Close()

Close - see interface 'statemgmt.RangeScanIterator' for details

func (*CompositeRangeScanIterator) GetKeyValue

func (itr *CompositeRangeScanIterator) GetKeyValue() (string, []byte)

GetKeyValue - see interface 'statemgmt.RangeScanIterator' for details

func (*CompositeRangeScanIterator) Next

func (itr *CompositeRangeScanIterator) Next() bool

Next - see interface 'statemgmt.RangeScanIterator' for details The specific implementation below starts from first underlying iterator and after exhausting the first underlying iterator, move to the second underlying iterator. The implementation repeats this until last underlying iterator has been exhausted In addition, the key-value from an underlying iterator are skipped if the key is found in any of the preceding iterators

type State

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

State structure for maintaining world state. This encapsulates a particular implementation for managing the state persistence This is not thread safe

func NewState

func NewState() *State

NewState constructs a new State. This Initializes encapsulated state implementation

func (*State) AddChangesForPersistence

func (state *State) AddChangesForPersistence(blockNumber uint64, writeBatch *gorocksdb.WriteBatch)

AddChangesForPersistence adds key-value pairs to writeBatch

func (*State) ApplyStateDelta

func (state *State) ApplyStateDelta(delta *statemgmt.StateDelta)

ApplyStateDelta applies already prepared stateDelta to the existing state. This is an in memory change only. state.CommitStateDelta must be used to commit the state to the DB. This method is to be used in state transfer.

func (*State) ClearInMemoryChanges

func (state *State) ClearInMemoryChanges(changesPersisted bool)

ClearInMemoryChanges remove from memory all the changes to state

func (*State) CommitStateDelta

func (state *State) CommitStateDelta() error

CommitStateDelta commits the changes from state.ApplyStateDelta to the DB.

func (*State) CopyState

func (state *State) CopyState(sourceChaincodeID string, destChaincodeID string) error

CopyState copies all the key-values from sourceChaincodeID to destChaincodeID

func (*State) Delete

func (state *State) Delete(chaincodeID string, key string) error

Delete tracks the deletion of state for chaincodeID and key. Does not immediately writes to DB

func (*State) DeleteState

func (state *State) DeleteState() error

DeleteState deletes ALL state keys/values from the DB. This is generally only used during state synchronization when creating a new state from a snapshot.

func (*State) FetchStateDeltaFromDB

func (state *State) FetchStateDeltaFromDB(blockNumber uint64) (*statemgmt.StateDelta, error)

FetchStateDeltaFromDB fetches the StateDelta corrsponding to given blockNumber

func (*State) Get

func (state *State) Get(chaincodeID string, key string, committed bool) ([]byte, error)

Get returns state for chaincodeID and key. If committed is false, this first looks in memory and if missing, pulls from db. If committed is true, this pulls from the db only.

func (*State) GetHash

func (state *State) GetHash() ([]byte, error)

GetHash computes new state hash if the stateDelta is to be applied. Recomputes only if stateDelta has changed after most recent call to this function

func (*State) GetMultipleKeys

func (state *State) GetMultipleKeys(chaincodeID string, keys []string, committed bool) ([][]byte, error)

GetMultipleKeys returns the values for the multiple keys.

func (*State) GetRangeScanIterator

func (state *State) GetRangeScanIterator(chaincodeID string, startKey string, endKey string, committed bool) (statemgmt.RangeScanIterator, error)

GetRangeScanIterator returns an iterator to get all the keys (and values) between startKey and endKey (assuming lexical order of the keys) for a chaincodeID.

func (*State) GetSnapshot

func (state *State) GetSnapshot(blockNumber uint64, dbSnapshot *gorocksdb.Snapshot) (*StateSnapshot, error)

GetSnapshot returns a snapshot of the global state for the current block. stateSnapshot.Release() must be called once you are done.

func (*State) GetTxStateDeltaHash

func (state *State) GetTxStateDeltaHash() map[string][]byte

GetTxStateDeltaHash return the hash of the StateDelta

func (*State) Set

func (state *State) Set(chaincodeID string, key string, value []byte) error

Set sets state to given value for chaincodeID and key. Does not immediately writes to DB

func (*State) SetMultipleKeys

func (state *State) SetMultipleKeys(chaincodeID string, kvs map[string][]byte) error

SetMultipleKeys sets the values for the multiple keys.

func (*State) TxBegin

func (state *State) TxBegin(txID string)

TxBegin marks begin of a new tx. If a tx is already in progress, this call panics

func (*State) TxFinish

func (state *State) TxFinish(txID string, txSuccessful bool)

TxFinish marks the completion of on-going tx. If txID is not same as of the on-going tx, this call panics

type StateSnapshot

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

StateSnapshot encapsulates StateSnapshotIterator given by actual state implementation and the db snapshot

func (*StateSnapshot) GetBlockNumber

func (ss *StateSnapshot) GetBlockNumber() uint64

GetBlockNumber returns the blocknumber associated with this global state snapshot

func (*StateSnapshot) GetRawKeyValue

func (ss *StateSnapshot) GetRawKeyValue() ([]byte, []byte)

GetRawKeyValue returns the raw bytes for the key and value at the current iterator position

func (*StateSnapshot) Next

func (ss *StateSnapshot) Next() bool

Next moves the iterator to the next key/value pair in the state

func (*StateSnapshot) Release

func (ss *StateSnapshot) Release()

Release the snapshot. This MUST be called when you are done with this resouce.

Jump to

Keyboard shortcuts

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