{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package persistence\n\n## Constants\n\n```go\nconst (\n\tChaincodePackageMetadataFile = \"Chaincode-Package-Metadata.json\"\n)\n```\n\n## Types\n\n```go\ntype ChaincodeMetadata struct {\n\tName    string `json:\"Name\"`\n\tVersion string `json:\"Version\"`\n}\n```\nChaincodeMetadata holds the name and version of a chaincode\n\n```go\ntype ChaincodePackage struct {\n\tMetadata    *ChaincodePackageMetadata\n\tCodePackage []byte\n}\n```\nChaincodePackage represents the un-tar-ed format of the chaincode package.\n\n```go\ntype ChaincodePackageMetadata struct {\n\tType string `json:\"Type\"`\n\tPath string `json:\"Path\"`\n}\n```\nChaincodePackageMetadata contains the information necessary to understand the embedded code package.\n\n```go\ntype ChaincodePackageParser struct{}\n```\nChaincodePackageParser provides the ability to parse chaincode packages\n\n```go\nfunc (ccpp ChaincodePackageParser) Parse(source []byte) (*ChaincodePackage, error)\n```\nParse parses a set of bytes as a chaincode package and returns the parsed package as a struct\n\n```go\ntype CodePackageNotFoundErr struct {\n\tName    string\n\tVersion string\n}\n```\nCodePackageNotFoundErr is the error returned when a code package cannot be found in the persistence store\n\n```go\nfunc (e *CodePackageNotFoundErr) Error() string\n```\n\n```go\ntype FilesystemIO struct {\n}\n```\nFilesystemIO is the production implementation of the IOWriter interface\n\n```go\nfunc (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error)\n```\nReadDir reads a directory from the filesystem\n\n```go\nfunc (f *FilesystemIO) ReadFile(filename string) ([]byte, error)\n```\nReadFile reads a file from the filesystem\n\n```go\nfunc (f *FilesystemIO) Remove(name string) error\n```\nRemove removes a file from the filesystem - used for rolling back an in-flight Save operation upon a failure\n\n```go\nfunc (f *FilesystemIO) Stat(name string) (os.FileInfo, error)\n```\nStat checks for existence of the file on the filesystem\n\n```go\nfunc (f *FilesystemIO) WriteFile(filename string, data []byte, perm os.FileMode) error\n```\nWriteFile writes a file to the filesystem\n\n```go\ntype IOReadWriter interface {\n\tReadDir(string) ([]os.FileInfo, error)\n\tReadFile(string) ([]byte, error)\n\tRemove(name string) error\n\tStat(string) (os.FileInfo, error)\n\tWriteFile(string, []byte, os.FileMode) error\n}\n```\nIOReadWriter defines the interface needed for reading, writing, removing, and checking for existence of a specified file\n\n```go\ntype LegacyPackageProvider interface {\n\tGetChaincodeCodePackage(name, version string) (codePackage []byte, err error)\n\tListInstalledChaincodes(dir string, de ccprovider.DirEnumerator, ce ccprovider.ChaincodeExtractor) ([]chaincode.InstalledChaincode, error)\n}\n```\nLegacyPackageProvider is the interface needed to retrieve the code package from a ChaincodeDeploymentSpec\n\n```go\ntype PackageParser interface {\n\tParse(data []byte) (*ChaincodePackage, error)\n}\n```\nPackageParser provides an implementation of chaincode package parsing\n\n```go\ntype PackageProvider struct {\n\tStore    StorePackageProvider\n\tParser   PackageParser\n\tLegacyPP LegacyPackageProvider\n}\n```\nPackageProvider holds the necessary dependencies to obtain the code package bytes for a chaincode\n\n```go\nfunc (p *PackageProvider) GetChaincodeCodePackage(name, version string) ([]byte, error)\n```\nGetChaincodeCodePackage gets the code package bytes for a chaincode given the name and version. It first searches through the persisted ChaincodeInstallPackages and then falls back to searching for ChaincodeDeploymentSpecs\n\n```go\nfunc (p *PackageProvider) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)\n```\nListInstalledChaincodes returns metadata (name, version, and ID) for each chaincode installed on a peer\n\n```go\ntype Store struct {\n\tPath       string\n\tReadWriter IOReadWriter\n}\n```\nStore holds the information needed for persisting a chaincode install package\n\n```go\nfunc (s *Store) GetChaincodeInstallPath() string\n```\nGetChaincodeInstallPath returns the path where chaincodes are installed\n\n```go\nfunc (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)\n```\nListInstalledChaincodes returns an array with information about the chaincodes installed in the persistence store\n\n```go\nfunc (s *Store) Load(hash []byte) (ccInstallPkg []byte, name, version string, err error)\n```\nLoad loads a persisted chaincode install package bytes with the given hash and also returns the name and version\n\n```go\nfunc (s *Store) LoadMetadata(path string) (name, version string, err error)\n```\nLoadMetadata loads the chaincode metadata stored at the specified path\n\n```go\nfunc (s *Store) RetrieveHash(name string, version string) ([]byte, error)\n```\nRetrieveHash retrieves the hash of a chaincode install package given the name and version of the chaincode\n\n```go\nfunc (s *Store) Save(name, version string, ccInstallPkg []byte) ([]byte, error)\n```\nSave persists chaincode install package bytes with the given name and version\n\n```go\ntype StorePackageProvider interface {\n\tGetChaincodeInstallPath() string\n\tListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)\n\tLoad(hash []byte) (codePackage []byte, name, version string, err error)\n\tRetrieveHash(name, version string) (hash []byte, err error)\n}\n```\nStorePackageProvider is the interface needed to retrieve the code package from a ChaincodeInstallPackage\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/chaincode/persistence","name":"persistence","synopsis":"","isRedistributable":true}
