Documentation ¶
Index ¶
- func ValidateRangeMetadata(metadata map[string]interface{}) error
- type BulkOptimizable
- type Cache
- func (c *Cache) Enabled(namespace string) bool
- func (c *Cache) GetState(chainID, namespace, key string) (*CacheValue, error)
- func (c *Cache) PutState(chainID, namespace, key string, cacheValue *CacheValue) error
- func (c *Cache) Reset()
- func (c *Cache) UpdateStates(chainID string, updates CacheUpdates) error
- type CacheKVs
- type CacheUpdates
- type CacheValue
- func (*CacheValue) Descriptor() ([]byte, []int)
- func (m *CacheValue) GetAdditionalInfo() []byte
- func (m *CacheValue) GetMetadata() []byte
- func (m *CacheValue) GetValue() []byte
- func (m *CacheValue) GetVersionBytes() []byte
- func (*CacheValue) ProtoMessage()
- func (m *CacheValue) Reset()
- func (m *CacheValue) String() string
- func (m *CacheValue) XXX_DiscardUnknown()
- func (m *CacheValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CacheValue) XXX_Merge(src proto.Message)
- func (m *CacheValue) XXX_Size() int
- func (m *CacheValue) XXX_Unmarshal(b []byte) error
- type CompositeKey
- type IndexCapable
- type QueryResult
- type QueryResultsIterator
- type ResultsIterator
- type UpdateBatch
- func (batch *UpdateBatch) Delete(ns string, key string, version *version.Height)
- func (batch *UpdateBatch) Exists(ns string, key string) bool
- func (batch *UpdateBatch) Get(ns string, key string) *VersionedValue
- func (batch *UpdateBatch) GetRangeScanIterator(ns string, startKey string, endKey string) QueryResultsIterator
- func (batch *UpdateBatch) GetUpdatedNamespaces() []string
- func (batch *UpdateBatch) GetUpdates(ns string) map[string]*VersionedValue
- func (batch *UpdateBatch) Merge(toMerge *UpdateBatch)
- func (batch *UpdateBatch) Put(ns string, key string, value []byte, version *version.Height)
- func (batch *UpdateBatch) PutValAndMetadata(ns string, key string, value []byte, metadata []byte, version *version.Height)
- func (batch *UpdateBatch) Update(ns string, key string, vv *VersionedValue)
- type VersionedDB
- type VersionedDBProvider
- type VersionedKV
- type VersionedValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRangeMetadata ¶
ValidateRangeMetadata validates the JSON containing attributes for the range query
Types ¶
type BulkOptimizable ¶
type BulkOptimizable interface { LoadCommittedVersions(keys []*CompositeKey) error GetCachedVersion(namespace, key string) (*version.Height, bool) ClearCachedVersions() }
BulkOptimizable interface provides additional functions for databases capable of batch operations
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds both the system and user cache
func NewCache ¶
NewCache creates a Cache. The cache consists of both system state cache (for lscc, _lifecycle) and user state cache (for all user deployed chaincodes). The size of the system state cache is 64 MB, by default. The size of the user state cache, in terms of MB, is specified via usrCacheSize parameter. Note that the maximum memory consumption of fastcache would be in the multiples of 32 MB (due to 512 buckets & an equal number of 64 KB chunks per bucket). If the usrCacheSizeMBs is not a multiple of 32 MB, the fastcache would round the size to the next multiple of 32 MB.
func (*Cache) Enabled ¶
Enabled returns true if the cache is enabled for a given namespace. Namespace can be of two types: system namespace (such as lscc) and user namespace (all user's chaincode states).
func (*Cache) GetState ¶
func (c *Cache) GetState(chainID, namespace, key string) (*CacheValue, error)
GetState returns the value for a given namespace and key from a cache associated with the chainID.
func (*Cache) PutState ¶
func (c *Cache) PutState(chainID, namespace, key string, cacheValue *CacheValue) error
PutState stores a given value in a cache associated with the chainID.
func (*Cache) UpdateStates ¶
func (c *Cache) UpdateStates(chainID string, updates CacheUpdates) error
UpdateStates updates only the existing entries in the cache associated with the chainID.
type CacheUpdates ¶
CacheUpdates is a map from a namespace to a set of cache KV updates
func (CacheUpdates) Add ¶
func (u CacheUpdates) Add(namespace string, ckvs CacheKVs)
Add adds the given cacheKVs to the CacheUpdates
type CacheValue ¶
type CacheValue struct { VersionBytes []byte `protobuf:"bytes,1,opt,name=version_bytes,json=versionBytes,proto3" json:"version_bytes,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` Metadata []byte `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` AdditionalInfo []byte `protobuf:"bytes,4,opt,name=additional_info,json=additionalInfo,proto3" json:"additional_info,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*CacheValue) Descriptor ¶
func (*CacheValue) Descriptor() ([]byte, []int)
func (*CacheValue) GetAdditionalInfo ¶
func (m *CacheValue) GetAdditionalInfo() []byte
func (*CacheValue) GetMetadata ¶
func (m *CacheValue) GetMetadata() []byte
func (*CacheValue) GetValue ¶
func (m *CacheValue) GetValue() []byte
func (*CacheValue) GetVersionBytes ¶
func (m *CacheValue) GetVersionBytes() []byte
func (*CacheValue) ProtoMessage ¶
func (*CacheValue) ProtoMessage()
func (*CacheValue) Reset ¶
func (m *CacheValue) Reset()
func (*CacheValue) String ¶
func (m *CacheValue) String() string
func (*CacheValue) XXX_DiscardUnknown ¶
func (m *CacheValue) XXX_DiscardUnknown()
func (*CacheValue) XXX_Marshal ¶
func (m *CacheValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*CacheValue) XXX_Merge ¶
func (m *CacheValue) XXX_Merge(src proto.Message)
func (*CacheValue) XXX_Size ¶
func (m *CacheValue) XXX_Size() int
func (*CacheValue) XXX_Unmarshal ¶
func (m *CacheValue) XXX_Unmarshal(b []byte) error
type CompositeKey ¶
CompositeKey encloses Namespace and Key components
type IndexCapable ¶
type IndexCapable interface { GetDBType() string ProcessIndexesForChaincodeDeploy(namespace string, fileEntries []*ccprovider.TarFileEntry) error }
IndexCapable interface provides additional functions for databases capable of index operations
type QueryResult ¶
type QueryResult interface{}
QueryResult - a general interface for supporting different types of query results. Actual types differ for different queries
type QueryResultsIterator ¶
type QueryResultsIterator interface { ResultsIterator GetBookmarkAndClose() string }
QueryResultsIterator adds GetBookmarkAndClose method
type ResultsIterator ¶
type ResultsIterator interface { Next() (QueryResult, error) Close() }
ResultsIterator iterates over query results
type UpdateBatch ¶
UpdateBatch encloses the details of multiple `updates`
func NewUpdateBatch ¶
func NewUpdateBatch() *UpdateBatch
NewUpdateBatch constructs an instance of a Batch
func (*UpdateBatch) Delete ¶
func (batch *UpdateBatch) Delete(ns string, key string, version *version.Height)
Delete deletes a Key and associated value
func (*UpdateBatch) Exists ¶
func (batch *UpdateBatch) Exists(ns string, key string) bool
Exists checks whether the given key exists in the batch
func (*UpdateBatch) Get ¶
func (batch *UpdateBatch) Get(ns string, key string) *VersionedValue
Get returns the VersionedValue for the given namespace and key
func (*UpdateBatch) GetRangeScanIterator ¶
func (batch *UpdateBatch) GetRangeScanIterator(ns string, startKey string, endKey string) QueryResultsIterator
GetRangeScanIterator returns an iterator that iterates over keys of a specific namespace in sorted order In other word this gives the same functionality over the contents in the `UpdateBatch` as `VersionedDB.GetStateRangeScanIterator()` method gives over the contents in the statedb This function can be used for querying the contents in the updateBatch before they are committed to the statedb. For instance, a validator implementation can used this to verify the validity of a range query of a transaction where the UpdateBatch represents the union of the modifications performed by the preceding valid transactions in the same block (Assuming Group commit approach where we commit all the updates caused by a block together).
func (*UpdateBatch) GetUpdatedNamespaces ¶
func (batch *UpdateBatch) GetUpdatedNamespaces() []string
GetUpdatedNamespaces returns the names of the namespaces that are updated
func (*UpdateBatch) GetUpdates ¶
func (batch *UpdateBatch) GetUpdates(ns string) map[string]*VersionedValue
GetUpdates returns all the updates for a namespace
func (*UpdateBatch) Merge ¶
func (batch *UpdateBatch) Merge(toMerge *UpdateBatch)
Merge merges another updates batch with this updates batch
func (*UpdateBatch) PutValAndMetadata ¶
func (batch *UpdateBatch) PutValAndMetadata(ns string, key string, value []byte, metadata []byte, version *version.Height)
PutValAndMetadata adds a key with value and metadata TODO introducing a new function to limit the refactoring. Later in a separate CR, the 'Put' function above should be removed
func (*UpdateBatch) Update ¶
func (batch *UpdateBatch) Update(ns string, key string, vv *VersionedValue)
Update updates the batch with a latest entry for a namespace and a key
type VersionedDB ¶
type VersionedDB interface { // GetState gets the value for given namespace and key. For a chaincode, the namespace corresponds to the chaincodeId GetState(namespace string, key string) (*VersionedValue, error) // GetVersion gets the version for given namespace and key. For a chaincode, the namespace corresponds to the chaincodeId GetVersion(namespace string, key string) (*version.Height, error) // GetStateMultipleKeys gets the values for multiple keys in a single call GetStateMultipleKeys(namespace string, keys []string) ([]*VersionedValue, error) // GetStateRangeScanIterator returns an iterator that contains all the key-values between given key ranges. // startKey is inclusive // endKey is exclusive // The returned ResultsIterator contains results of type *VersionedKV GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ResultsIterator, error) // GetStateRangeScanIteratorWithMetadata returns an iterator that contains all the key-values between given key ranges. // startKey is inclusive // endKey is exclusive // metadata is a map of additional query parameters // The returned ResultsIterator contains results of type *VersionedKV GetStateRangeScanIteratorWithMetadata(namespace string, startKey string, endKey string, metadata map[string]interface{}) (QueryResultsIterator, error) // ExecuteQuery executes the given query and returns an iterator that contains results of type *VersionedKV. ExecuteQuery(namespace, query string) (ResultsIterator, error) // ExecuteQueryWithMetadata executes the given query with associated query options and // returns an iterator that contains results of type *VersionedKV. // metadata is a map of additional query parameters ExecuteQueryWithMetadata(namespace, query string, metadata map[string]interface{}) (QueryResultsIterator, error) // ApplyUpdates applies the batch to the underlying db. // height is the height of the highest transaction in the Batch that // a state db implementation is expected to ues as a save point ApplyUpdates(batch *UpdateBatch, height *version.Height) error // GetLatestSavePoint returns the height of the highest transaction upto which // the state db is consistent GetLatestSavePoint() (*version.Height, error) // ValidateKeyValue tests whether the key and value is supported by the db implementation. // For instance, leveldb supports any bytes for the key while the couchdb supports only valid utf-8 string // TODO make the function ValidateKeyValue return a specific error say ErrInvalidKeyValue // However, as of now, the both implementations of this function (leveldb and couchdb) are deterministic in returing an error // i.e., an error is returned only if the key-value are found to be invalid for the underlying db ValidateKeyValue(key string, value []byte) error // BytesKeySupported returns true if the implementation (underlying db) supports the any bytes to be used as key. // For instance, leveldb supports any bytes for the key while the couchdb supports only valid utf-8 string BytesKeySupported() bool // Open opens the db Open() error // Close closes the db Close() }
VersionedDB lists methods that a db is supposed to implement
type VersionedDBProvider ¶
type VersionedDBProvider interface { // GetDBHandle returns a handle to a VersionedDB GetDBHandle(id string) (VersionedDB, error) // Close closes all the VersionedDB instances and releases any resources held by VersionedDBProvider Close() }
VersionedDBProvider provides an instance of an versioned DB
type VersionedKV ¶
type VersionedKV struct { CompositeKey VersionedValue }
VersionedKV encloses key and corresponding VersionedValue
type VersionedValue ¶
VersionedValue encloses value and corresponding version
func (*VersionedValue) IsDelete ¶
func (vv *VersionedValue) IsDelete() bool
IsDelete returns true if this update indicates delete of a key