{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package privdata\n\n## Functions\n\n```go\nfunc BuildCollectionKVSKey(ccname string) string\n```\nBuildCollectionKVSKey constructs the collection config key for a given chaincode name\n\n```go\nfunc GetCCNameFromCollectionConfigKey(key string) string\n```\nGetCCNameFromCollectionConfigKey returns the chaincode name given a collection config key\n\n```go\nfunc IsCollectionConfigKey(key string) bool\n```\nIsCollectionConfigKey detects if a key is a collection key\n\n```go\nfunc ParseCollectionConfig(colBytes []byte) (*common.CollectionConfigPackage, error)\n```\nParseCollectionConfig parses the collection configuration from the given serialized representation\n\n```go\nfunc RetrieveCollectionConfigPackageFromState(cc common.CollectionCriteria, state State) (*common.CollectionConfigPackage, error)\n```\nRetrieveCollectionConfigPackageFromState retrieves the collection config package from the given key from the given state\n\n## Types\n\n```go\ntype Collection interface {\n\n\t// CollectionID returns this collection's ID\n\tCollectionID() string\n\n\t// MemberOrgs returns the collection's members as MSP IDs. This serves as\n\t// a human-readable way of quickly identifying who is part of a collection.\n\tMemberOrgs() []string\n}\n```\nCollection defines a common interface for collections\n\n```go\ntype CollectionAccessPolicy interface {\n\t// AccessFilter returns a member filter function for a collection\n\tAccessFilter() Filter\n\n\t// The minimum number of peers private data will be sent to upon\n\t// endorsement. The endorsement would fail if dissemination to at least\n\t// this number of peers is not achieved.\n\tRequiredPeerCount() int\n\n\t// The maximum number of peers that private data will be sent to\n\t// upon endorsement. This number has to be bigger than RequiredPeerCount().\n\tMaximumPeerCount() int\n\n\t// MemberOrgs returns the collection's members as MSP IDs. This serves as\n\t// a human-readable way of quickly identifying who is part of a collection.\n\tMemberOrgs() []string\n\n\t// IsMemberOnlyRead returns a true if only collection members can read\n\t// the private data\n\tIsMemberOnlyRead() bool\n}\n```\nCollectionAccessPolicy encapsulates functions for the access policy of a collection\n\n```go\ntype CollectionFilter interface {\n\t// AccessFilter retrieves the collection's filter that matches a given channel and a collectionPolicyConfig\n\tAccessFilter(channelName string, collectionPolicyConfig *common.CollectionPolicyConfig) (Filter, error)\n}\n```\n\n```go\ntype CollectionPersistenceConfigs interface {\n\t// BlockToLive returns the number of blocks after which the collection data expires.\n\t// For instance if the value is set to 10, a key last modified by block number 100\n\t// will be purged at block number 111. A zero value is treated same as MaxUint64\n\tBlockToLive() uint64\n}\n```\nCollectionPersistenceConfigs encapsulates configurations related to persistence of a collection\n\n```go\ntype CollectionStore interface {\n\t// RetrieveCollection retrieves the collection in the following way:\n\t// If the TxID exists in the ledger, the collection that is returned has the\n\t// latest configuration that was committed into the ledger before this txID\n\t// was committed.\n\t// Else - it's the latest configuration for the collection.\n\tRetrieveCollection(common.CollectionCriteria) (Collection, error)\n\n\t// RetrieveCollectionAccessPolicy retrieves a collection's access policy\n\tRetrieveCollectionAccessPolicy(common.CollectionCriteria) (CollectionAccessPolicy, error)\n\n\t// RetrieveCollectionConfigPackage retrieves the whole configuration package\n\t// for the chaincode with the supplied criteria\n\tRetrieveCollectionConfigPackage(common.CollectionCriteria) (*common.CollectionConfigPackage, error)\n\n\t// RetrieveCollectionPersistenceConfigs retrieves the collection's persistence related configurations\n\tRetrieveCollectionPersistenceConfigs(common.CollectionCriteria) (CollectionPersistenceConfigs, error)\n\n\t// HasReadAccess checks whether the creator of the signedProposal has read permission on a\n\t// given collection\n\tHasReadAccess(common.CollectionCriteria, *pb.SignedProposal, ledger.QueryExecutor) (bool, error)\n\n\tCollectionFilter\n}\n```\nCollectionStore provides various APIs to retrieves stored collections and perform membership check \u0026 read permission check based on the collection's properties. TODO: Refactor CollectionStore - FAB-13082 (1) function such as RetrieveCollection() and RetrieveCollectionConfigPackage() are\n\n\tnever used except in mocks and test files.\n\n(2) in gossip, at least in 7 different places, the following 3 operations\n\n\tare repeated which can be avoided by introducing a API called IsAMemberOf().\n\t    (i)   retrieves collection access policy by calling RetrieveCollectionAccessPolicy()\n\t    (ii)  get the access filter func from the collection access policy\n\t    (iii) create the evaluation policy and check for membership\n\n(3) we would need a cache in collection store to avoid repeated crypto operation.\n\n\tThis would be simple to implement when we introduce IsAMemberOf() APIs.\n\n```go\nfunc NewSimpleCollectionStore(s Support) CollectionStore\n```\nNewSimpleCollectionStore returns a collection stored backed by a ledger supplied by the specified ledgerGetter with an internal name formed as specified by the supplied collectionNamer function\n\n```go\ntype Filter func(common.SignedData) bool\n```\nFilter defines a rule that filters peers according to data signed by them. The Identity in the SignedData is a SerializedIdentity of a peer. The Data is a message the peer signed, and the Signature is the corresponding Signature on that Data. Returns: True, if the policy holds for the given signed data.\n\n\tFalse otherwise\n\n```go\ntype MembershipProvider struct {\n\tIdentityDeserializerFactory func(chainID string) msp.IdentityDeserializer\n\t// contains filtered or unexported fields\n}\n```\nMembershipProvider can be used to check whether a peer is eligible to a collection or not\n\n```go\nfunc NewMembershipInfoProvider(selfSignedData common.SignedData, identityDeserializerFunc func(chainID string) msp.IdentityDeserializer) *MembershipProvider\n```\nNewMembershipInfoProvider returns MembershipProvider\n\n```go\nfunc (m *MembershipProvider) AmMemberOf(channelName string, collectionPolicyConfig *common.CollectionPolicyConfig) (bool, error)\n```\nAmMemberOf checks whether the current peer is a member of the given collection config. If getPolicy returns an error, it will drop the error and return false - same as a RejectAll policy.\n\n```go\ntype NoSuchCollectionError common.CollectionCriteria\n```\n\n```go\nfunc (f NoSuchCollectionError) Error() string\n```\n\n```go\ntype SimpleCollection struct {\n\t// contains filtered or unexported fields\n}\n```\nSimpleCollection implements a collection with static properties and a public member set\n\n```go\nfunc (sc *SimpleCollection) AccessFilter() Filter\n```\nAccessFilter returns the member filter function that evaluates signed data against the member access policy of this collection\n\n```go\nfunc (sc *SimpleCollection) CollectionID() string\n```\nCollectionID returns the collection's ID\n\n```go\nfunc (sc *SimpleCollection) IsMemberOnlyRead() bool\n```\n\n```go\nfunc (sc *SimpleCollection) MaximumPeerCount() int\n```\n\n```go\nfunc (sc *SimpleCollection) MemberOrgs() []string\n```\nMemberOrgs returns the MSP IDs that are part of this collection\n\n```go\nfunc (sc *SimpleCollection) RequiredPeerCount() int\n```\nRequiredPeerCount returns the minimum number of peers required to send private data to\n\n```go\nfunc (sc *SimpleCollection) Setup(collectionConfig *common.StaticCollectionConfig, deserializer msp.IdentityDeserializer) error\n```\nSetup configures a simple collection object based on a given StaticCollectionConfig proto that has all the necessary information\n\n```go\ntype SimpleCollectionPersistenceConfigs struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *SimpleCollectionPersistenceConfigs) BlockToLive() uint64\n```\nBlockToLive return collection's block to live configuration\n\n```go\ntype State interface {\n\t// GetState retrieves the value for the given key in the given namespace\n\tGetState(namespace string, key string) ([]byte, error)\n}\n```\nStateGetter retrieves data from the state\n\n```go\ntype Support interface {\n\t// GetQueryExecutorForLedger returns a query executor for the specified channel\n\tGetQueryExecutorForLedger(cid string) (ledger.QueryExecutor, error)\n\n\t// GetIdentityDeserializer returns an IdentityDeserializer\n\t// instance for the specified chain\n\tGetIdentityDeserializer(chainID string) msp.IdentityDeserializer\n}\n```\nSupport is an interface used to inject dependencies\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/common/privdata","name":"privdata","synopsis":"","isRedistributable":true}
