Documentation ¶
Index ¶
- Constants
- Variables
- func CCFileName(packageID string) string
- func ValidateLabel(label string) error
- type ChaincodePackage
- type ChaincodePackageLocator
- type ChaincodePackageMetadata
- type ChaincodePackageParser
- type ChaincodePackageStreamer
- 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)
- type CodePackageNotFoundErr
- type FallbackPackageLocator
- type FilesystemIO
- func (*FilesystemIO) Exists(path string) (bool, error)
- func (f *FilesystemIO) MakeDir(dirname string, mode os.FileMode) error
- func (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error)
- func (f *FilesystemIO) ReadFile(filename string) ([]byte, error)
- func (f *FilesystemIO) Remove(name string) error
- func (f *FilesystemIO) WriteFile(path, name string, data []byte) error
- type IOReadWriter
- type LegacyCCPackageLocator
- type MetadataProvider
- type Store
- func (s *Store) Delete(packageID string) error
- func (s *Store) GetChaincodeInstallPath() string
- func (s *Store) Initialize()
- func (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
- func (s *Store) Load(packageID string) ([]byte, error)
- func (s *Store) Save(label string, ccInstallPkg []byte) (string, error)
- type TarFileStream
Constants ¶
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" )
Variables ¶
var LabelRegexp = regexp.MustCompile(`^[[:alnum:]][[:alnum:]_.+-]*$`)
LabelRegexp is the regular expression controlling the allowed characters for the package label.
Functions ¶
Types ¶
type ChaincodePackage ¶
type ChaincodePackage struct { Metadata *ChaincodePackageMetadata CodePackage []byte DBArtifacts []byte }
ChaincodePackage represents the un-tar-ed format of the chaincode package.
type ChaincodePackageLocator ¶
type ChaincodePackageLocator struct {
ChaincodeDir string
}
func (*ChaincodePackageLocator) ChaincodePackageStreamer ¶
func (cpl *ChaincodePackageLocator) ChaincodePackageStreamer(packageID string) *ChaincodePackageStreamer
type ChaincodePackageMetadata ¶
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 ¶
type ChaincodePackageParser struct {
MetadataProvider MetadataProvider
}
ChaincodePackageParser provides the ability to parse chaincode packages.
func (ChaincodePackageParser) Parse ¶
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
type ChaincodePackageStreamer ¶
type ChaincodePackageStreamer struct {
PackagePath string
}
func (*ChaincodePackageStreamer) Code ¶
func (cps *ChaincodePackageStreamer) Code() (*TarFileStream, error)
func (*ChaincodePackageStreamer) Exists ¶
func (cps *ChaincodePackageStreamer) Exists() bool
func (*ChaincodePackageStreamer) File ¶
func (cps *ChaincodePackageStreamer) File(name string) (tarFileStream *TarFileStream, err error)
func (*ChaincodePackageStreamer) Metadata ¶
func (cps *ChaincodePackageStreamer) Metadata() (*ChaincodePackageMetadata, error)
func (*ChaincodePackageStreamer) MetadataBytes ¶
func (cps *ChaincodePackageStreamer) MetadataBytes() ([]byte, error)
type CodePackageNotFoundErr ¶
type CodePackageNotFoundErr struct {
PackageID string
}
CodePackageNotFoundErr is the error returned when a code package cannot be found in the persistence store
func (CodePackageNotFoundErr) Error ¶
func (e CodePackageNotFoundErr) Error() string
type FallbackPackageLocator ¶
type FallbackPackageLocator struct { ChaincodePackageLocator *ChaincodePackageLocator LegacyCCPackageLocator LegacyCCPackageLocator }
func (*FallbackPackageLocator) GetChaincodePackage ¶
func (fpl *FallbackPackageLocator) GetChaincodePackage(packageID string) (*ChaincodePackageMetadata, []byte, io.ReadCloser, error)
type FilesystemIO ¶
type FilesystemIO struct { }
FilesystemIO is the production implementation of the IOWriter interface
func (*FilesystemIO) Exists ¶
func (*FilesystemIO) Exists(path string) (bool, error)
Exists checks whether a file exists
func (*FilesystemIO) MakeDir ¶
func (f *FilesystemIO) MakeDir(dirname string, mode os.FileMode) error
MakeDir makes a directory on the filesystem (and any necessary parent directories).
func (*FilesystemIO) ReadDir ¶
func (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error)
ReadDir reads a directory from the filesystem
func (*FilesystemIO) ReadFile ¶
func (f *FilesystemIO) ReadFile(filename string) ([]byte, error)
ReadFile reads a file from the filesystem
func (*FilesystemIO) Remove ¶
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 (*FilesystemIO) WriteFile ¶
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 ¶
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 ¶
type LegacyCCPackageLocator interface {
GetChaincodeDepSpec(nameVersion string) (*pb.ChaincodeDeploymentSpec, error)
}
type MetadataProvider ¶
MetadataProvider provides the means to retrieve metadata information (for instance the DB indexes) from a code package.
type Store ¶
type Store struct { Path string ReadWriter IOReadWriter }
Store holds the information needed for persisting a chaincode install package
func NewStore ¶
NewStore creates a new chaincode persistence store using the provided path on the filesystem.
func (*Store) Delete ¶
Delete deletes a persisted chaincode. Note, there is no locking, so this should only be performed if the chaincode has already been marked built.
func (*Store) GetChaincodeInstallPath ¶
GetChaincodeInstallPath returns the path where chaincodes are installed
func (*Store) Initialize ¶
func (s *Store) Initialize()
Initialize checks for the existence of the _lifecycle chaincodes directory and creates it if it has not yet been created.
func (*Store) ListInstalledChaincodes ¶
func (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
ListInstalledChaincodes returns an array with information about the chaincodes installed in the persistence store
func (*Store) Load ¶
Load loads a persisted chaincode install package bytes with the given packageID.