privacyenabledstate

package
v2.2.4-gm Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CouchDBTestEnv

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

CouchDBTestEnv implements TestEnv interface for couchdb based storage

func (*CouchDBTestEnv) Cleanup

func (env *CouchDBTestEnv) Cleanup()

Cleanup implements corresponding function from interface TestEnv

func (*CouchDBTestEnv) DBValueFormat

func (env *CouchDBTestEnv) DBValueFormat() byte

DBValueFormat returns the format used by the stateleveldb for dbvalue Not yet implemented

func (*CouchDBTestEnv) DecodeDBValue

func (env *CouchDBTestEnv) DecodeDBValue(dbVal []byte) statedb.VersionedValue

DecodeDBValue decodes the dbvalue bytes for tests Not yet implemented

func (*CouchDBTestEnv) GetDBHandle

func (env *CouchDBTestEnv) GetDBHandle(id string) *DB

GetDBHandle implements corresponding function from interface TestEnv

func (*CouchDBTestEnv) GetName

func (env *CouchDBTestEnv) GetName() string

GetName implements corresponding function from interface TestEnv

func (*CouchDBTestEnv) Init

func (env *CouchDBTestEnv) Init(t testing.TB)

Init implements corresponding function from interface TestEnv

func (*CouchDBTestEnv) StartExternalResource

func (env *CouchDBTestEnv) StartExternalResource()

StartExternalResource starts external couchDB resources.

func (*CouchDBTestEnv) StopExternalResource

func (env *CouchDBTestEnv) StopExternalResource()

StopExternalResource stops external couchDB resources.

type DB

type DB struct {
	statedb.VersionedDB
	// contains filtered or unexported fields
}

DB uses a single database to maintain both the public and private data

func NewDB

func NewDB(vdb statedb.VersionedDB, ledgerid string, metadataHint *metadataHint) (*DB, error)

NewDB wraps a VersionedDB instance. The public data is managed directly by the wrapped versionedDB. For managing the hashed data and private data, this implementation creates separate namespaces in the wrapped db

func (*DB) ApplyPrivacyAwareUpdates

func (s *DB) ApplyPrivacyAwareUpdates(updates *UpdateBatch, height *version.Height) error

ApplyPrivacyAwareUpdates applies the batch to the underlying db

func (*DB) ApplyUpdates

func (s *DB) ApplyUpdates(batch *statedb.UpdateBatch, height *version.Height) error

ApplyUpdates overrides the function in statedb.VersionedDB and throws appropriate error message Otherwise, somewhere in the code, usage of this function could lead to updating only public data.

func (*DB) ChaincodeDeployDone

func (s *DB) ChaincodeDeployDone(succeeded bool)

ChaincodeDeployDone is a noop for couchdb state impl

func (*DB) ClearCachedVersions

func (s *DB) ClearCachedVersions()

ClearCachedVersions clears the version cache

func (DB) ExecuteQueryOnPrivateData

func (s DB) ExecuteQueryOnPrivateData(namespace, collection, query string) (statedb.ResultsIterator, error)

ExecuteQuery executes the given query and returns an iterator that contains results of type specific to the underlying data store.

func (*DB) ExportPubStateAndPvtStateHashes

func (s *DB) ExportPubStateAndPvtStateHashes(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error)

ExportPubStateAndPvtStateHashes generates four files in the specified dir. The files, public_state.data and public_state.metadata contains the exported public state and the files private_state_hashes.data and private_state_hashes.data contain the exported private state hashes. The file format for public state and the private state hashes are the same. The data files contains a series of tuple <key,value> and the metadata files contains a series of tuple <namespace, num entries for the namespace in the data file>.

func (*DB) GetCachedKeyHashVersion

func (s *DB) GetCachedKeyHashVersion(namespace, collection string, keyHash []byte) (*version.Height, bool)

GetCachedKeyHashVersion retrieves the keyhash version from cache

func (*DB) GetChaincodeEventListener

func (s *DB) GetChaincodeEventListener() cceventmgmt.ChaincodeLifecycleEventListener

GetChaincodeEventListener returns a struct that implements cceventmgmt.ChaincodeLifecycleEventListener if the underlying statedb implements statedb.IndexCapable.

func (*DB) GetKeyHashVersion

func (s *DB) GetKeyHashVersion(namespace, collection string, keyHash []byte) (*version.Height, error)

GetKeyHashVersion gets the version of a private data item identified by a tuple <namespace, collection, keyHash>

func (*DB) GetPrivateData

func (s *DB) GetPrivateData(namespace, collection, key string) (*statedb.VersionedValue, error)

GetPrivateData gets the value of a private data item identified by a tuple <namespace, collection, key>

func (*DB) GetPrivateDataHash

func (s *DB) GetPrivateDataHash(namespace, collection, key string) (*statedb.VersionedValue, error)

GetPrivateDataHash gets the hash of the value of a private data item identified by a tuple <namespace, collection, key>

func (*DB) GetPrivateDataMetadataByHash

func (s *DB) GetPrivateDataMetadataByHash(namespace, collection string, keyHash []byte) ([]byte, error)

GetPrivateDataMetadataByHash implements corresponding function in interface DB. For additional details, see description of the similar function 'GetStateMetadata'

func (*DB) GetPrivateDataMultipleKeys

func (s *DB) GetPrivateDataMultipleKeys(namespace, collection string, keys []string) ([]*statedb.VersionedValue, error)

GetPrivateDataMultipleKeys gets the values for the multiple private data items in a single call

func (*DB) GetPrivateDataRangeScanIterator

func (s *DB) GetPrivateDataRangeScanIterator(namespace, collection, startKey, endKey string) (statedb.ResultsIterator, error)

GetPrivateDataRangeScanIterator returns an iterator that contains all the key-values between given key ranges. startKey is included in the results and endKey is excluded.

func (*DB) GetStateMetadata

func (s *DB) GetStateMetadata(namespace, key string) ([]byte, error)

GetStateMetadata implements corresponding function in interface DB. This implementation provides an optimization such that it keeps track if a namespaces has never stored metadata for any of its items, the value 'nil' is returned without going to the db. This is intended to be invoked in the validation and commit path. This saves the chaincodes from paying unnecessary performance penalty if they do not use features that leverage metadata (such as key-level endorsement),

func (*DB) GetValueHash

func (s *DB) GetValueHash(namespace, collection string, keyHash []byte) (*statedb.VersionedValue, error)

GetPrivateDataHash gets the value hash of a private data item identified by a tuple <namespace, collection, keyHash>

func (*DB) HandleChaincodeDeploy

func (s *DB) HandleChaincodeDeploy(chaincodeDefinition *cceventmgmt.ChaincodeDefinition, dbArtifactsTar []byte) error

HandleChaincodeDeploy initializes database artifacts for the database associated with the namespace This function deliberately suppresses the errors that occur during the creation of the indexes on couchdb. This is because, in the present code, we do not differentiate between the errors because of couchdb interaction and the errors because of bad index files - the later being unfixable by the admin. Note that the error suppression is acceptable since peer can continue in the committing role without the indexes. However, executing chaincode queries may be affected, until a new chaincode with fixed indexes is installed and instantiated

func (*DB) IsBulkOptimizable

func (s *DB) IsBulkOptimizable() bool

IsBulkOptimizable checks whether the underlying statedb implements statedb.BulkOptimizable

func (*DB) LoadCommittedVersionsOfPubAndHashedKeys

func (s *DB) LoadCommittedVersionsOfPubAndHashedKeys(pubKeys []*statedb.CompositeKey,
	hashedKeys []*HashedCompositeKey) error

LoadCommittedVersionsOfPubAndHashedKeys loads committed version of given public and hashed states

type DBProvider

type DBProvider struct {
	VersionedDBProvider statedb.VersionedDBProvider
	HealthCheckRegistry ledger.HealthCheckRegistry
	// contains filtered or unexported fields
}

DBProvider encapsulates other providers such as VersionedDBProvider and BookeepingProvider which are required to create DB for a channel

func NewDBProvider

func NewDBProvider(
	bookkeeperProvider bookkeeping.Provider,
	metricsProvider metrics.Provider,
	healthCheckRegistry ledger.HealthCheckRegistry,
	stateDBConf *StateDBConfig,
	sysNamespaces []string,
) (*DBProvider, error)

NewDBProvider constructs an instance of DBProvider

func (*DBProvider) Close

func (p *DBProvider) Close()

Close closes all the VersionedDB instances and releases any resources held by VersionedDBProvider

func (*DBProvider) GetDBHandle

func (p *DBProvider) GetDBHandle(id string, chInfoProvider channelInfoProvider) (*DB, error)

GetDBHandle gets a handle to DB for a given id, i.e., a channel

func (*DBProvider) RegisterHealthChecker

func (p *DBProvider) RegisterHealthChecker() error

RegisterHealthChecker registers the underlying stateDB with the healthChecker. For now, we register only the CouchDB as it runs as a separate process but not for the GoLevelDB as it is an embedded database.

type HashedCompositeKey

type HashedCompositeKey struct {
	Namespace      string
	CollectionName string
	KeyHash        string
}

HashedCompositeKey encloses Namespace, CollectionName and KeyHash components

func (*HashedCompositeKey) String

func (hck *HashedCompositeKey) String() string

String returns a print friendly form of HashedCompositeKey

type HashedUpdateBatch

type HashedUpdateBatch struct {
	UpdateMap
}

HashedUpdateBatch contains updates for the hashes of the private data

func NewHashedUpdateBatch

func NewHashedUpdateBatch() *HashedUpdateBatch

NewHashedUpdateBatch creates an empty HashedUpdateBatch

func (HashedUpdateBatch) Contains

func (h HashedUpdateBatch) Contains(ns, coll string, keyHash []byte) bool

Contains returns true if the given <ns,coll,keyHash> tuple is present in the batch

func (HashedUpdateBatch) Delete

func (h HashedUpdateBatch) Delete(ns, coll string, key []byte, version *version.Height)

Delete overrides the function in UpdateMap for allowing the key to be a []byte instead of a string

func (HashedUpdateBatch) Put

func (h HashedUpdateBatch) Put(ns, coll string, key []byte, value []byte, version *version.Height)

Put overrides the function in UpdateMap for allowing the key to be a []byte instead of a string

func (HashedUpdateBatch) PutValHashAndMetadata

func (h HashedUpdateBatch) PutValHashAndMetadata(ns, coll string, key []byte, value []byte, metadata []byte, version *version.Height)

PutValHashAndMetadata 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 (HashedUpdateBatch) ToCompositeKeyMap

func (h HashedUpdateBatch) ToCompositeKeyMap() map[HashedCompositeKey]*statedb.VersionedValue

ToCompositeKeyMap rearranges the update batch data in the form of a single map

type LevelDBTestEnv

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

LevelDBTestEnv implements TestEnv interface for leveldb based storage

func (*LevelDBTestEnv) Cleanup

func (env *LevelDBTestEnv) Cleanup()

Cleanup implements corresponding function from interface TestEnv

func (*LevelDBTestEnv) DBValueFormat

func (env *LevelDBTestEnv) DBValueFormat() byte

DBValueFormat returns the format used by the stateleveldb for dbvalue

func (*LevelDBTestEnv) DecodeDBValue

func (env *LevelDBTestEnv) DecodeDBValue(dbVal []byte) statedb.VersionedValue

DecodeDBValue decodes the dbvalue bytes for tests

func (*LevelDBTestEnv) GetDBHandle

func (env *LevelDBTestEnv) GetDBHandle(id string) *DB

GetDBHandle implements corresponding function from interface TestEnv

func (*LevelDBTestEnv) GetName

func (env *LevelDBTestEnv) GetName() string

GetName implements corresponding function from interface TestEnv

func (*LevelDBTestEnv) Init

func (env *LevelDBTestEnv) Init(t testing.TB)

Init implements corresponding function from interface TestEnv

func (*LevelDBTestEnv) StartExternalResource

func (env *LevelDBTestEnv) StartExternalResource()

StartExternalResource will be an empty implementation for levelDB test environment.

func (*LevelDBTestEnv) StopExternalResource

func (env *LevelDBTestEnv) StopExternalResource()

StopExternalResource will be an empty implementation for levelDB test environment.

type NsBatch

type NsBatch struct {
	*statedb.UpdateBatch
}

nsBatch contains updates related to one namespace

func (NsBatch) GetCollectionNames

func (nsb NsBatch) GetCollectionNames() []string

func (NsBatch) GetCollectionUpdates

func (nsb NsBatch) GetCollectionUpdates(collName string) map[string]*statedb.VersionedValue

type PubUpdateBatch

type PubUpdateBatch struct {
	*statedb.UpdateBatch
}

PubUpdateBatch contains update for the public data

func NewPubUpdateBatch

func NewPubUpdateBatch() *PubUpdateBatch

NewPubUpdateBatch creates an empty PubUpdateBatch

type PvtKVWrite

type PvtKVWrite struct {
	Key      string
	IsDelete bool
	Value    []byte
	Version  *version.Height
}

PvtKVWrite encloses Key, IsDelete, Value, and Version components

type PvtUpdateBatch

type PvtUpdateBatch struct {
	UpdateMap
}

PvtUpdateBatch contains updates for the private data

func NewPvtUpdateBatch

func NewPvtUpdateBatch() *PvtUpdateBatch

NewPvtUpdateBatch creates an empty PvtUpdateBatch

func (PvtUpdateBatch) ToCompositeKeyMap

func (p PvtUpdateBatch) ToCompositeKeyMap() PvtdataCompositeKeyMap

ToCompositeKeyMap rearranges the update batch data in the form of a single map

type PvtdataCompositeKey

type PvtdataCompositeKey struct {
	Namespace      string
	CollectionName string
	Key            string
}

PvtdataCompositeKey encloses Namespace, CollectionName and Key components

type PvtdataCompositeKeyMap

type PvtdataCompositeKeyMap map[PvtdataCompositeKey]*statedb.VersionedValue

PvtdataCompositeKeyMap is a map of PvtdataCompositeKey to VersionedValue

type StateDBConfig

type StateDBConfig struct {
	// ledger.StateDBConfig is used to configure the stateDB for the ledger.
	*ledger.StateDBConfig
	// LevelDBPath is the filesystem path when statedb type is "goleveldb".
	// It is internally computed by the ledger component,
	// so it is not in ledger.StateDBConfig and not exposed to other components.
	LevelDBPath string
}

StateDBConfig encapsulates the configuration for stateDB on the ledger.

type TestEnv

type TestEnv interface {
	StartExternalResource()
	Init(t testing.TB)
	GetDBHandle(id string) *DB
	GetName() string
	DBValueFormat() byte
	DecodeDBValue(dbVal []byte) statedb.VersionedValue
	Cleanup()
	StopExternalResource()
}

TestEnv - an interface that a test environment implements

type UpdateBatch

type UpdateBatch struct {
	PubUpdates  *PubUpdateBatch
	HashUpdates *HashedUpdateBatch
	PvtUpdates  *PvtUpdateBatch
}

UpdateBatch encapsulates the updates to Public, Private, and Hashed data. This is expected to contain a consistent set of updates

func NewUpdateBatch

func NewUpdateBatch() *UpdateBatch

NewUpdateBatch creates and empty UpdateBatch

type UpdateMap

type UpdateMap map[string]NsBatch

UpdateMap maintains entries of tuple <Namespace, UpdatesForNamespace>

func (UpdateMap) Contains

func (b UpdateMap) Contains(ns, coll, key string) bool

Contains returns true if the given <ns,coll,key> tuple is present in the batch

func (UpdateMap) Delete

func (b UpdateMap) Delete(ns, coll, key string, version *version.Height)

Delete adds a delete marker in the batch for a given combination of namespace and collection name

func (UpdateMap) Get

func (b UpdateMap) Get(ns, coll, key string) *statedb.VersionedValue

Get retrieves the value from the batch for a given combination of namespace and collection name

func (UpdateMap) GetUpdatedNamespaces

func (b UpdateMap) GetUpdatedNamespaces() []string

func (UpdateMap) IsEmpty

func (b UpdateMap) IsEmpty() bool

IsEmpty returns true if there exists any updates

func (UpdateMap) Put

func (b UpdateMap) Put(ns, coll, key string, value []byte, version *version.Height)

Put sets the value in the batch for a given combination of namespace and collection name

func (UpdateMap) PutValAndMetadata

func (b UpdateMap) PutValAndMetadata(ns, coll, key string, value []byte, metadata []byte, version *version.Height)

PutValAndMetadata adds a key with value and metadata

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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