{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ccprovider\n\n## Functions\n\n```go\nfunc ChaincodePackageExists(ccname string, ccversion string) (bool, error)\n```\nChaincodePackageExists returns whether the chaincode package exists in the file system\n\n```go\nfunc CheckInstantiationPolicy(name, version string, cdLedger *ChaincodeData) error\n```\n\n```go\nfunc ExtractFileEntries(tarBytes []byte, databaseType string) (map[string][]*TarFileEntry, error)\n```\nExtractFileEntries extract file entries from the given \\`tarBytes\\`. A file entry is included in the returned results only if it is located in a directory under the indicated databaseType directory Example for chaincode indexes: \"META-INF/statedb/couchdb/indexes/indexColorSortName.json\" Example for collection scoped indexes: \"META-INF/statedb/couchdb/collections/collectionMarbles/indexes/indexCollMarbles.json\" An empty string will have the effect of returning all statedb metadata.  This is useful in validating an archive in the future with multiple database types\n\n```go\nfunc ExtractStatedbArtifactsForChaincode(ccname, ccversion string, pr *platforms.Registry) (installed bool, statedbArtifactsTar []byte, err error)\n```\nExtractStatedbArtifactsAsTarbytes extracts the statedb artifacts from the code package tar and create a statedb artifact tar. The state db artifacts are expected to contain state db specific artifacts such as index specification in the case of couchdb. This function is intended to be used during chaincode instantiate/upgrade so that statedb artifacts can be created.\n\n```go\nfunc ExtractStatedbArtifactsFromCCPackage(ccpackage CCPackage, pr *platforms.Registry) (statedbArtifactsTar []byte, err error)\n```\nExtractStatedbArtifactsFromCCPackage extracts the statedb artifacts from the code package tar and create a statedb artifact tar. The state db artifacts are expected to contain state db specific artifacts such as index specification in the case of couchdb. This function is called during chaincode instantiate/upgrade (from above), and from install, so that statedb artifacts can be created.\n\n```go\nfunc GetChaincodeInstallPathFromViper() string\n```\nGetChaincodeInstallPathFromViper returns the path where chaincodes are installed\n\n```go\nfunc GetChaincodePackage(ccname string, ccversion string) ([]byte, error)\n```\n\n```go\nfunc GetChaincodePackageFromPath(ccname string, ccversion string, ccInstallPath string) ([]byte, error)\n```\nGetChaincodePackage returns the chaincode package from the file system\n\n```go\nfunc GetInstalledChaincodes() (*pb.ChaincodeQueryResponse, error)\n```\nGetInstalledChaincodes returns a map whose key is the chaincode id and value is the ChaincodeDeploymentSpec struct for that chaincodes that have been installed (but not necessarily instantiated) on the peer by searching the chaincode install path\n\n```go\nfunc IsChaincodeDeployed(chainid, ccName, ccVersion string, ccHash []byte, sccp sysccprovider.SystemChaincodeProvider) (bool, error)\n```\nIsChaincodeDeployed returns true if the chaincode with given name and version is deployed\n\n```go\nfunc NewCCInfoCache(cs CCCacheSupport) *ccInfoCacheImpl\n```\nNewCCInfoCache returns a new cache on top of the supplied CCInfoProvider instance\n\n```go\nfunc PutChaincodeIntoFS(depSpec *pb.ChaincodeDeploymentSpec) error\n```\nPutChaincodeIntoFS puts chaincode information in the file system (and also in the cache to prime it) if the cache is enabled, or directly from the file system otherwise\n\n```go\nfunc SetChaincodesPath(path string)\n```\nSetChaincodesPath sets the chaincode path for this peer\n\n## Types\n\n```go\ntype CCCacheSupport interface {\n\t// GetChaincode is needed by the cache to get chaincode data\n\tGetChaincode(ccname string, ccversion string) (CCPackage, error)\n}\n```\n\n```go\ntype CCContext struct {\n\t// Name chaincode name\n\tName string\n\n\t// Version used to construct the chaincode image and register\n\tVersion string\n}\n```\nCCContext pass this around instead of string of args\n\n```go\nfunc (cccid *CCContext) GetCanonicalName() string\n```\nGetCanonicalName returns the canonical name associated with the proposal context\n\n```go\ntype CCInfoFSImpl struct{}\n```\nCCInfoFSImpl provides the implementation for CC on the FS and the access to it It implements CCCacheSupport\n\n```go\nfunc (cifs *CCInfoFSImpl) GetChaincode(ccname string, ccversion string) (CCPackage, error)\n```\nGetChaincodeFromFS this is a wrapper for hiding package implementation. It calls GetChaincodeFromPath with the chaincodeInstallPath\n\n```go\nfunc (cifs *CCInfoFSImpl) GetChaincodeCodePackage(ccname, ccversion string) ([]byte, error)\n```\n\n```go\nfunc (*CCInfoFSImpl) GetChaincodeFromPath(ccname string, ccversion string, path string) (CCPackage, error)\n```\nGetChaincodeFromPath this is a wrapper for hiding package implementation.\n\n```go\nfunc (cifs *CCInfoFSImpl) ListInstalledChaincodes(dir string, ls DirEnumerator, ccFromPath ChaincodeExtractor) ([]chaincode.InstalledChaincode, error)\n```\nListInstalledChaincodes retrieves the installed chaincodes\n\n```go\nfunc (*CCInfoFSImpl) PutChaincode(depSpec *pb.ChaincodeDeploymentSpec) (CCPackage, error)\n```\nPutChaincodeIntoFS is a wrapper for putting raw ChaincodeDeploymentSpec using CDSPackage. This is only used in UTs\n\n```go\ntype CCPackage interface {\n\t//InitFromBuffer initialize the package from bytes\n\tInitFromBuffer(buf []byte) (*ChaincodeData, error)\n\n\t// InitFromFS gets the chaincode from the filesystem (includes the raw bytes too)\n\tInitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)\n\n\t// PutChaincodeToFS writes the chaincode to the filesystem\n\tPutChaincodeToFS() error\n\n\t// GetDepSpec gets the ChaincodeDeploymentSpec from the package\n\tGetDepSpec() *pb.ChaincodeDeploymentSpec\n\n\t// GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package\n\tGetDepSpecBytes() []byte\n\n\t// ValidateCC validates and returns the chaincode deployment spec corresponding to\n\t// ChaincodeData. The validation is based on the metadata from ChaincodeData\n\t// One use of this method is to validate the chaincode before launching\n\tValidateCC(ccdata *ChaincodeData) error\n\n\t// GetPackageObject gets the object as a proto.Message\n\tGetPackageObject() proto.Message\n\n\t// GetChaincodeData gets the ChaincodeData\n\tGetChaincodeData() *ChaincodeData\n\n\t// GetId gets the fingerprint of the chaincode based on package computation\n\tGetId() []byte\n}\n```\nCCPackage encapsulates a chaincode package which can be\n\n\traw ChaincodeDeploymentSpec\n\tSignedChaincodeDeploymentSpec\n\nAttempt to keep the interface at a level with minimal interface for possible generalization.\n\n```go\nfunc GetCCPackage(buf []byte) (CCPackage, error)\n```\nGetCCPackage tries each known package implementation one by one till the right package is found\n\n```go\nfunc GetChaincodeFromFS(ccname string, ccversion string) (CCPackage, error)\n```\nGetChaincodeFromFS retrieves chaincode information from the file system\n\n```go\nfunc LoadPackage(ccname string, ccversion string, path string) (CCPackage, error)\n```\nLoadPackage loads a chaincode package from the file system\n\n```go\ntype CDSData struct {\n\t//CodeHash hash of CodePackage from ChaincodeDeploymentSpec\n\tCodeHash []byte `protobuf:\"bytes,1,opt,name=codehash,proto3\"`\n\n\t//MetaDataHash hash of Name and Version from ChaincodeDeploymentSpec\n\tMetaDataHash []byte `protobuf:\"bytes,2,opt,name=metadatahash,proto3\"`\n}\n```\nCDSData is data stored in the LSCC on instantiation of a CC for CDSPackage.  This needs to be serialized for ChaincodeData hence the protobuf format\n\n```go\nfunc (data *CDSData) Equals(other *CDSData) bool\n```\nEquals data equals other\n\n```go\nfunc (*CDSData) ProtoMessage()\n```\nProtoMessage just exists to make proto happy\n\n```go\nfunc (data *CDSData) Reset()\n```\nReset resets\n\n```go\nfunc (data *CDSData) String() string\n```\nString converts to string\n\n```go\ntype CDSPackage struct {\n\t// contains filtered or unexported fields\n}\n```\nCDSPackage encapsulates ChaincodeDeploymentSpec.\n\n```go\nfunc (ccpack *CDSPackage) GetChaincodeData() *ChaincodeData\n```\nGetChaincodeData gets the ChaincodeData\n\n```go\nfunc (ccpack *CDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec\n```\nGetDepSpec gets the ChaincodeDeploymentSpec from the package\n\n```go\nfunc (ccpack *CDSPackage) GetDepSpecBytes() []byte\n```\nGetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package\n\n```go\nfunc (ccpack *CDSPackage) GetId() []byte\n```\nGetId gets the fingerprint of the chaincode based on package computation\n\n```go\nfunc (ccpack *CDSPackage) GetPackageObject() proto.Message\n```\nGetPackageObject gets the ChaincodeDeploymentSpec as proto.Message\n\n```go\nfunc (ccpack *CDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)\n```\nInitFromBuffer sets the buffer if valid and returns ChaincodeData\n\n```go\nfunc (ccpack *CDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)\n```\nInitFromFS returns the chaincode and its package from the file system\n\n```go\nfunc (ccpack *CDSPackage) InitFromPath(ccname string, ccversion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error)\n```\nInitFromFS returns the chaincode and its package from the file system\n\n```go\nfunc (ccpack *CDSPackage) PutChaincodeToFS() error\n```\nPutChaincodeToFS - serializes chaincode to a package on the file system\n\n```go\nfunc (ccpack *CDSPackage) ValidateCC(ccdata *ChaincodeData) error\n```\nValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec\n\n```go\ntype ChaincodeContainerInfo struct {\n\tName        string\n\tVersion     string\n\tPath        string\n\tType        string\n\tCodePackage []byte\n\n\t// ContainerType is not a great name, but 'DOCKER' and 'SYSTEM' are the valid types\n\tContainerType string\n}\n```\nChaincodeContainerInfo is yet another synonym for the data required to start/stop a chaincode.\n\n```go\nfunc DeploymentSpecToChaincodeContainerInfo(cds *pb.ChaincodeDeploymentSpec) *ChaincodeContainerInfo\n```\n\n```go\ntype ChaincodeData struct {\n\t// Name of the chaincode\n\tName string `protobuf:\"bytes,1,opt,name=name\"`\n\n\t// Version of the chaincode\n\tVersion string `protobuf:\"bytes,2,opt,name=version\"`\n\n\t// Escc for the chaincode instance\n\tEscc string `protobuf:\"bytes,3,opt,name=escc\"`\n\n\t// Vscc for the chaincode instance\n\tVscc string `protobuf:\"bytes,4,opt,name=vscc\"`\n\n\t// Policy endorsement policy for the chaincode instance\n\tPolicy []byte `protobuf:\"bytes,5,opt,name=policy,proto3\"`\n\n\t// Data data specific to the package\n\tData []byte `protobuf:\"bytes,6,opt,name=data,proto3\"`\n\n\t// Id of the chaincode that's the unique fingerprint for the CC This is not\n\t// currently used anywhere but serves as a good eyecatcher\n\tId []byte `protobuf:\"bytes,7,opt,name=id,proto3\"`\n\n\t// InstantiationPolicy for the chaincode\n\tInstantiationPolicy []byte `protobuf:\"bytes,8,opt,name=instantiation_policy,proto3\"`\n}\n```\nChaincodeData defines the datastructure for chaincodes to be serialized by proto Type provides an additional check by directing to use a specific package after instantiation Data is Type specific (see CDSPackage and SignedCDSPackage)\n\n```go\nfunc GetChaincodeData(ccname string, ccversion string) (*ChaincodeData, error)\n```\nGetChaincodeData gets chaincode data from cache if there's one\n\n```go\nfunc (cd *ChaincodeData) CCName() string\n```\nCCName returns the name of this chaincode (the name it was put in the ChaincodeRegistry with).\n\n```go\nfunc (cd *ChaincodeData) CCVersion() string\n```\nCCVersion returns the version of the chaincode.\n\n```go\nfunc (cd *ChaincodeData) Endorsement() string\n```\nEndorsement returns how to endorse proposals for this chaincode. The string returns is the name of the endorsement method (usually 'escc').\n\n```go\nfunc (cd *ChaincodeData) Hash() []byte\n```\nHash returns the hash of the chaincode.\n\n```go\nfunc (*ChaincodeData) ProtoMessage()\n```\nProtoMessage just exists to make proto happy\n\n```go\nfunc (cd *ChaincodeData) Reset()\n```\nReset resets\n\n```go\nfunc (cd *ChaincodeData) String() string\n```\nString converts to string\n\n```go\nfunc (cd *ChaincodeData) Validation() (string, []byte)\n```\nValidation returns how to validate transactions for this chaincode. The string returned is the name of the validation method (usually 'vscc') and the bytes returned are the argument to the validation (in the case of 'vscc', this is a marshaled pb.VSCCArgs message).\n\n```go\ntype ChaincodeDefinition interface {\n\t// CCName returns the name of this chaincode (the name it was put in the ChaincodeRegistry with).\n\tCCName() string\n\n\t// Hash returns the hash of the chaincode.\n\tHash() []byte\n\n\t// CCVersion returns the version of the chaincode.\n\tCCVersion() string\n\n\t// Validation returns how to validate transactions for this chaincode.\n\t// The string returned is the name of the validation method (usually 'vscc')\n\t// and the bytes returned are the argument to the validation (in the case of\n\t// 'vscc', this is a marshaled pb.VSCCArgs message).\n\tValidation() (string, []byte)\n\n\t// Endorsement returns how to endorse proposals for this chaincode.\n\t// The string returns is the name of the endorsement method (usually 'escc').\n\tEndorsement() string\n}\n```\n\\-------- ChaincodeDefinition - interface for ChaincodeData ------ ChaincodeDefinition describes all of the necessary information for a peer to decide whether to endorse a proposal and whether to validate a transaction, for a particular chaincode.\n\n```go\ntype ChaincodeExtractor func(ccname string, ccversion string, path string) (CCPackage, error)\n```\nChaincodeExtractor extracts chaincode from a given path\n\n```go\ntype ChaincodeProvider interface {\n\t// Execute executes a standard chaincode invocation for a chaincode and an input\n\tExecute(txParams *TransactionParams, cccid *CCContext, input *pb.ChaincodeInput) (*pb.Response, *pb.ChaincodeEvent, error)\n\t// ExecuteLegacyInit is a special case for executing chaincode deployment specs,\n\t// which are not already in the LSCC, needed for old lifecycle\n\tExecuteLegacyInit(txParams *TransactionParams, cccid *CCContext, spec *pb.ChaincodeDeploymentSpec) (*pb.Response, *pb.ChaincodeEvent, error)\n\t// Stop stops the chaincode give\n\tStop(ccci *ChaincodeContainerInfo) error\n}\n```\nChaincodeProvider provides an abstraction layer that is used for different packages to interact with code in the chaincode package without importing it; more methods should be added below if necessary\n\n```go\ntype DirEnumerator func(string) ([]os.FileInfo, error)\n```\nDirEnumerator enumerates directories\n\n```go\ntype SignedCDSData struct {\n\tCodeHash      []byte `protobuf:\"bytes,1,opt,name=hash\"`\n\tMetaDataHash  []byte `protobuf:\"bytes,2,opt,name=metadatahash\"`\n\tSignatureHash []byte `protobuf:\"bytes,3,opt,name=signaturehash\"`\n}\n```\nSignedCDSData is data stored in the LSCC on instantiation of a CC for SignedCDSPackage. This needs to be serialized for ChaincodeData hence the protobuf format\n\n```go\nfunc (data *SignedCDSData) Equals(other *SignedCDSData) bool\n```\nEquals data equals other\n\n```go\nfunc (*SignedCDSData) ProtoMessage()\n```\nProtoMessage just exists to make proto happy\n\n```go\nfunc (data *SignedCDSData) Reset()\n```\nReset resets\n\n```go\nfunc (data *SignedCDSData) String() string\n```\nString converts to string\n\n```go\ntype SignedCDSPackage struct {\n\t// contains filtered or unexported fields\n}\n```\nSignedCDSPackage encapsulates SignedChaincodeDeploymentSpec.\n\n```go\nfunc (ccpack *SignedCDSPackage) GetChaincodeData() *ChaincodeData\n```\nGetChaincodeData gets the ChaincodeData\n\n```go\nfunc (ccpack *SignedCDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec\n```\nGetDepSpec gets the ChaincodeDeploymentSpec from the package\n\n```go\nfunc (ccpack *SignedCDSPackage) GetDepSpecBytes() []byte\n```\nGetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package\n\n```go\nfunc (ccpack *SignedCDSPackage) GetId() []byte\n```\nGetId gets the fingerprint of the chaincode based on package computation\n\n```go\nfunc (ccpack *SignedCDSPackage) GetInstantiationPolicy() []byte\n```\nGetInstantiationPolicy gets the instantiation policy from the package\n\n```go\nfunc (ccpack *SignedCDSPackage) GetPackageObject() proto.Message\n```\nGetPackageObject gets the ChaincodeDeploymentSpec as proto.Message\n\n```go\nfunc (ccpack *SignedCDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)\n```\nInitFromBuffer sets the buffer if valid and returns ChaincodeData\n\n```go\nfunc (ccpack *SignedCDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)\n```\nInitFromFS returns the chaincode and its package from the file system\n\n```go\nfunc (ccpack *SignedCDSPackage) InitFromPath(ccname string, ccversion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error)\n```\nInitFromPath returns the chaincode and its package from the file system\n\n```go\nfunc (ccpack *SignedCDSPackage) PutChaincodeToFS() error\n```\nPutChaincodeToFS - serializes chaincode to a package on the file system\n\n```go\nfunc (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error\n```\nValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec\n\n```go\ntype TarFileEntry struct {\n\tFileHeader  *tar.Header\n\tFileContent []byte\n}\n```\ntarFileEntry encapsulates a file entry and it's contents inside a tar\n\n```go\ntype TransactionParams struct {\n\tTxID                 string\n\tChannelID            string\n\tSignedProp           *pb.SignedProposal\n\tProposal             *pb.Proposal\n\tTXSimulator          ledger.TxSimulator\n\tHistoryQueryExecutor ledger.HistoryQueryExecutor\n\tCollectionStore      privdata.CollectionStore\n\tIsInitTransaction    bool\n\n\t// this is additional data passed to the chaincode\n\tProposalDecorations map[string][]byte\n}\n```\nTransactionParams are parameters which are tied to a particular transaction and which are required for invoking chaincode.\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/common/ccprovider","name":"ccprovider","synopsis":"","isRedistributable":true}
