{"modulePath":"https-1xa.pages.dev/hyperledger/fabric","version":"v2.1.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package persistence\n\n## Constants\n\n```go\nconst (\n\t// MetadataFile is the expected location of the metadata json document\n\t// in the top level of the chaincode package.\n\tMetadataFile = \"metadata.json\"\n\n\t// CodePackageFile is the expected location of the code package in the\n\t// top level of the chaincode package\n\tCodePackageFile = \"code.tar.gz\"\n)\n```\n\n## Variables\n\n```go\nvar LabelRegexp = regexp.MustCompile(`^[[:alnum:]][[:alnum:]_.+-]*$`)\n```\nLabelRegexp is the regular expression controlling the allowed characters for the package label.\n\n## Functions\n\n```go\nfunc CCFileName(packageID string) string\n```\n\n```go\nfunc ValidateLabel(label string) error\n```\nValidateLabel return an error if the provided label contains any invalid characters, as determined by LabelRegexp.\n\n## Types\n\n```go\ntype ChaincodePackage struct {\n\tMetadata    *ChaincodePackageMetadata\n\tCodePackage []byte\n\tDBArtifacts []byte\n}\n```\nChaincodePackage represents the un-tar-ed format of the chaincode package.\n\n```go\ntype ChaincodePackageLocator struct {\n\tChaincodeDir string\n}\n```\n\n```go\nfunc (cpl *ChaincodePackageLocator) ChaincodePackageStreamer(packageID string) *ChaincodePackageStreamer\n```\n\n```go\ntype ChaincodePackageMetadata struct {\n\tType  string `json:\"type\"`\n\tPath  string `json:\"path\"`\n\tLabel string `json:\"label\"`\n}\n```\nChaincodePackageMetadata contains the information necessary to understand the embedded code package.\n\n```go\ntype ChaincodePackageParser struct {\n\tMetadataProvider MetadataProvider\n}\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 ChaincodePackageStreamer struct {\n\tPackagePath string\n}\n```\n\n```go\nfunc (cps *ChaincodePackageStreamer) Code() (*TarFileStream, error)\n```\n\n```go\nfunc (cps *ChaincodePackageStreamer) Exists() bool\n```\n\n```go\nfunc (cps *ChaincodePackageStreamer) File(name string) (tarFileStream *TarFileStream, err error)\n```\n\n```go\nfunc (cps *ChaincodePackageStreamer) Metadata() (*ChaincodePackageMetadata, error)\n```\n\n```go\nfunc (cps *ChaincodePackageStreamer) MetadataBytes() ([]byte, error)\n```\n\n```go\ntype CodePackageNotFoundErr struct {\n\tPackageID 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 FallbackPackageLocator struct {\n\tChaincodePackageLocator *ChaincodePackageLocator\n\tLegacyCCPackageLocator  LegacyCCPackageLocator\n}\n```\n\n```go\nfunc (fpl *FallbackPackageLocator) GetChaincodePackage(packageID string) (*ChaincodePackageMetadata, []byte, io.ReadCloser, error)\n```\n\n```go\ntype FilesystemIO struct {\n}\n```\nFilesystemIO is the production implementation of the IOWriter interface\n\n```go\nfunc (*FilesystemIO) Exists(path string) (bool, error)\n```\nExists checks whether a file exists\n\n```go\nfunc (f *FilesystemIO) MakeDir(dirname string, mode os.FileMode) error\n```\nMakeDir makes a directory on the filesystem (and any necessary parent directories).\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) WriteFile(path, name string, data []byte) error\n```\nWriteFile writes a file to the filesystem; it does so atomically by first writing to a temp file and then renaming the file so that if the operation crashes midway we're not stuck with a bad package\n\n```go\ntype IOReadWriter interface {\n\tReadDir(string) ([]os.FileInfo, error)\n\tReadFile(string) ([]byte, error)\n\tRemove(name string) error\n\tWriteFile(string, string, []byte) error\n\tMakeDir(string, os.FileMode) error\n\tExists(path string) (bool, error)\n}\n```\nIOReadWriter defines the interface needed for reading, writing, removing, and checking for existence of a specified file\n\n```go\ntype LegacyCCPackageLocator interface {\n\tGetChaincodeDepSpec(nameVersion string) (*pb.ChaincodeDeploymentSpec, error)\n}\n```\n\n```go\ntype MetadataProvider interface {\n\tGetDBArtifacts(codePackage []byte) ([]byte, error)\n}\n```\nMetadataProvider provides the means to retrieve metadata information (for instance the DB indexes) from a code package.\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 NewStore(path string) *Store\n```\nNewStore creates a new chaincode persistence store using the provided path on the filesystem.\n\n```go\nfunc (s *Store) Delete(packageID string) error\n```\nDelete deletes a persisted chaincode.  Note, there is no locking, so this should only be performed if the chaincode has already been marked built.\n\n```go\nfunc (s *Store) GetChaincodeInstallPath() string\n```\nGetChaincodeInstallPath returns the path where chaincodes are installed\n\n```go\nfunc (s *Store) Initialize()\n```\nInitialize checks for the existence of the \\_lifecycle chaincodes directory and creates it if it has not yet been created.\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(packageID string) ([]byte, error)\n```\nLoad loads a persisted chaincode install package bytes with the given packageID.\n\n```go\nfunc (s *Store) Save(label string, ccInstallPkg []byte) (string, error)\n```\nSave persists chaincode install package bytes. It returns the hash of the chaincode install package\n\n```go\ntype TarFileStream struct {\n\tTarFile    io.Reader\n\tFileStream io.Closer\n}\n```\n\n```go\nfunc (tfs *TarFileStream) Close() error\n```\n\n```go\nfunc (tfs *TarFileStream) Read(p []byte) (int, error)\n```\n\n","path":"https-1xa.pages.dev/hyperledger/fabric/core/chaincode/persistence","name":"persistence","synopsis":"","isRedistributable":true}
