Version: v0.1.0 Latest Latest

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

Go to latest
Published: Feb 15, 2016 License: Apache-2.0 Imports: 9 Imported by: 20




This section is empty.


This section is empty.


This section is empty.


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

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

Delete tracks the deletion of state for chaincodeID and key. Does not immideatly 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) 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 immideatly writes to DB

func (*State) TxBegin

func (state *State) TxBegin(txUUID 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(txUUID string, txSuccessful bool)

TxFinish marks the completion of on-going tx. If txUUID 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