import "github.com/hyperledger/fabric/core/chaincode/persistence"
chaincode_package.go persistence.go
const ( // MetadataFile is the expected location of the metadata json document // in the top level of the chaincode package. MetadataFile = "metadata.json" // CodePackageFile is the expected location of the code package in the // top level of the chaincode package CodePackageFile = "code.tar.gz" )
var LabelRegexp = regexp.MustCompile(`^[[:alnum:]][[:alnum:]_.+-]*$`)
LabelRegexp is the regular expression controlling the allowed characters for the package label.
ValidateLabel return an error if the provided label contains any invalid characters, as determined by LabelRegexp.
type ChaincodePackage struct { Metadata *ChaincodePackageMetadata CodePackage []byte DBArtifacts []byte }
ChaincodePackage represents the un-tar-ed format of the chaincode package.
func (cpl *ChaincodePackageLocator) ChaincodePackageStreamer(packageID string) *ChaincodePackageStreamer
type ChaincodePackageMetadata struct { Type string `json:"type"` Path string `json:"path"` Label string `json:"label"` }
ChaincodePackageMetadata contains the information necessary to understand the embedded code package.
type ChaincodePackageParser struct { MetadataProvider MetadataProvider }
ChaincodePackageParser provides the ability to parse chaincode packages.
func (ccpp ChaincodePackageParser) Parse(source []byte) (*ChaincodePackage, error)
Parse parses a set of bytes as a chaincode package and returns the parsed package as a struct
func (cps *ChaincodePackageStreamer) Code() (*TarFileStream, error)
func (cps *ChaincodePackageStreamer) Exists() bool
func (cps *ChaincodePackageStreamer) File(name string) (tarFileStream *TarFileStream, err error)
func (cps *ChaincodePackageStreamer) Metadata() (*ChaincodePackageMetadata, error)
func (cps *ChaincodePackageStreamer) MetadataBytes() ([]byte, error)
CodePackageNotFoundErr is the error returned when a code package cannot be found in the persistence store
func (e CodePackageNotFoundErr) Error() string
type FallbackPackageLocator struct { ChaincodePackageLocator *ChaincodePackageLocator LegacyCCPackageLocator LegacyCCPackageLocator }
func (fpl *FallbackPackageLocator) GetChaincodePackage(packageID string) (*ChaincodePackageMetadata, []byte, io.ReadCloser, error)
type FilesystemIO struct { }
FilesystemIO is the production implementation of the IOWriter interface
func (*FilesystemIO) Exists(path string) (bool, error)
Exists checks whether a file exists
MakeDir makes a directory on the filesystem (and any necessary parent directories).
ReadDir reads a directory from the filesystem
func (f *FilesystemIO) ReadFile(filename string) ([]byte, error)
ReadFile reads a file from the filesystem
func (f *FilesystemIO) Remove(name string) error
Remove removes a file from the filesystem - used for rolling back an in-flight Save operation upon a failure
func (f *FilesystemIO) WriteFile(path, name string, data []byte) error
WriteFile 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
type IOReadWriter interface { ReadDir(string) ([]os.FileInfo, error) ReadFile(string) ([]byte, error) Remove(name string) error WriteFile(string, string, []byte) error MakeDir(string, os.FileMode) error Exists(path string) (bool, error) }
IOReadWriter defines the interface needed for reading, writing, removing, and checking for existence of a specified file
type LegacyCCPackageLocator interface { GetChaincodeDepSpec(nameVersion string) (*pb.ChaincodeDeploymentSpec, error) }
MetadataProvider provides the means to retrieve metadata information (for instance the DB indexes) from a code package.
type Store struct { Path string ReadWriter IOReadWriter }
Store holds the information needed for persisting a chaincode install package
NewStore creates a new chaincode persistence store using the provided path on the filesystem.
Delete deletes a persisted chaincode. Note, there is no locking, so this should only be performed if the chaincode has already been marked built.
GetChaincodeInstallPath returns the path where chaincodes are installed
Initialize checks for the existence of the _lifecycle chaincodes directory and creates it if it has not yet been created.
func (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
ListInstalledChaincodes returns an array with information about the chaincodes installed in the persistence store
Load loads a persisted chaincode install package bytes with the given packageID.
Save persists chaincode install package bytes. It returns the hash of the chaincode install package
func (tfs *TarFileStream) Close() error
func (tfs *TarFileStream) Read(p []byte) (int, error)
Path | Synopsis |
---|---|
mock | Code generated by counterfeiter. |
Package persistence imports 17 packages (graph) and is imported by 18 packages. Updated 2020-07-15. Refresh now. Tools for package owners.