Documentation ¶
Index ¶
- type CompositeRangeScanIterator
- type State
- func (state *State) AddChangesForPersistence(blockNumber uint64, writeBatch *gorocksdb.WriteBatch)
- func (state *State) ApplyStateDelta(delta *statemgmt.StateDelta)
- func (state *State) ClearInMemoryChanges(changesPersisted bool)
- func (state *State) CommitStateDelta() error
- func (state *State) CopyState(sourceChaincodeID string, destChaincodeID string) error
- func (state *State) Delete(chaincodeID string, key string) error
- func (state *State) DeleteState() error
- func (state *State) FetchStateDeltaFromDB(blockNumber uint64) (*statemgmt.StateDelta, error)
- func (state *State) Get(chaincodeID string, key string, committed bool) ([]byte, error)
- func (state *State) GetHash() ([]byte, error)
- func (state *State) GetMultipleKeys(chaincodeID string, keys []string, committed bool) ([][]byte, error)
- func (state *State) GetRangeScanIterator(chaincodeID string, startKey string, endKey string, committed bool) (statemgmt.RangeScanIterator, error)
- func (state *State) GetSnapshot(blockNumber uint64, dbSnapshot *gorocksdb.Snapshot) (*StateSnapshot, error)
- func (state *State) GetTxStateDeltaHash() map[string][]byte
- func (state *State) Set(chaincodeID string, key string, value []byte) error
- func (state *State) SetMultipleKeys(chaincodeID string, kvs map[string][]byte) error
- func (state *State) TxBegin(txID string)
- func (state *State) TxFinish(txID string, txSuccessful bool)
- type StateSnapshot
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 ¶
ClearInMemoryChanges remove from memory all the changes to state
func (*State) CommitStateDelta ¶
CommitStateDelta commits the changes from state.ApplyStateDelta to the DB.
func (*State) CopyState ¶
CopyState copies all the key-values from sourceChaincodeID to destChaincodeID
func (*State) Delete ¶
Delete tracks the deletion of state for chaincodeID and key. Does not immediately writes to DB
func (*State) DeleteState ¶
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 ¶
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 ¶
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 ¶
GetTxStateDeltaHash return the hash of the StateDelta
func (*State) Set ¶
Set sets state to given value for chaincodeID and key. Does not immediately writes to DB
func (*State) SetMultipleKeys ¶
SetMultipleKeys sets the values for the multiple keys.
func (*State) TxBegin ¶
TxBegin marks begin of a new tx. If a tx is already in progress, 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.