fabric: github.com/hyperledger/fabric/core/chaincode/persistence Index | Files | Directories

package persistence

import "github.com/hyperledger/fabric/core/chaincode/persistence"

Index

Package Files

chaincode_package.go persistence.go

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 is the regular expression controlling
    // the allowed characters for the package label
    LabelRegexp = regexp.MustCompile("^[a-zA-Z0-9]+([.+-_][a-zA-Z0-9]+)*$")
)

func CCFileName Uses

func CCFileName(packageID string) string

type ChaincodePackage Uses

type ChaincodePackage struct {
    Metadata    *ChaincodePackageMetadata
    CodePackage []byte
    DBArtifacts []byte
}

ChaincodePackage represents the un-tar-ed format of the chaincode package.

type ChaincodePackageLocator Uses

type ChaincodePackageLocator struct {
    ChaincodeDir string
}

func (*ChaincodePackageLocator) ChaincodePackageStreamer Uses

func (cpl *ChaincodePackageLocator) ChaincodePackageStreamer(packageID string) *ChaincodePackageStreamer

type ChaincodePackageMetadata Uses

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 Uses

type ChaincodePackageParser struct {
    MetadataProvider MetadataProvider
}

ChaincodePackageParser provides the ability to parse chaincode packages.

func (ChaincodePackageParser) Parse Uses

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 Uses

type ChaincodePackageStreamer struct {
    PackagePath string
}

func (*ChaincodePackageStreamer) Code Uses

func (cps *ChaincodePackageStreamer) Code() (*TarFileStream, error)

func (*ChaincodePackageStreamer) Exists Uses

func (cps *ChaincodePackageStreamer) Exists() bool

func (*ChaincodePackageStreamer) File Uses

func (cps *ChaincodePackageStreamer) File(name string) (tarFileStream *TarFileStream, err error)

func (*ChaincodePackageStreamer) Metadata Uses

func (cps *ChaincodePackageStreamer) Metadata() (*ChaincodePackageMetadata, error)

type CodePackageNotFoundErr Uses

type CodePackageNotFoundErr struct {
    PackageID string
}

CodePackageNotFoundErr is the error returned when a code package cannot be found in the persistence store

func (CodePackageNotFoundErr) Error Uses

func (e CodePackageNotFoundErr) Error() string

type FallbackPackageLocator Uses

type FallbackPackageLocator struct {
    ChaincodePackageLocator *ChaincodePackageLocator
    LegacyCCPackageLocator  LegacyCCPackageLocator
}

func (*FallbackPackageLocator) GetChaincodePackage Uses

func (fpl *FallbackPackageLocator) GetChaincodePackage(packageID string) (*ChaincodePackageMetadata, io.ReadCloser, error)

type FilesystemIO Uses

type FilesystemIO struct {
}

FilesystemIO is the production implementation of the IOWriter interface

func (*FilesystemIO) Exists Uses

func (*FilesystemIO) Exists(path string) (bool, error)

Exists checks whether a file exists

func (*FilesystemIO) MakeDir Uses

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 Uses

func (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir reads a directory from the filesystem

func (*FilesystemIO) ReadFile Uses

func (f *FilesystemIO) ReadFile(filename string) ([]byte, error)

ReadFile reads a file from the filesystem

func (*FilesystemIO) Remove Uses

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 Uses

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 Uses

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 Uses

type LegacyCCPackageLocator interface {
    GetChaincodeDepSpec(nameVersion string) (*pb.ChaincodeDeploymentSpec, error)
}

type MetadataProvider Uses

type MetadataProvider interface {
    GetDBArtifacts(codePackage []byte) ([]byte, error)
}

MetadataProvider provides the means to retrieve metadata information (for instance the DB indexes) from a code package.

type Store Uses

type Store struct {
    Path       string
    ReadWriter IOReadWriter
}

Store holds the information needed for persisting a chaincode install package

func NewStore Uses

func NewStore(path string) *Store

NewStore creates a new chaincode persistence store using the provided path on the filesystem.

func (*Store) Delete Uses

func (s *Store) Delete(packageID string) error

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 Uses

func (s *Store) GetChaincodeInstallPath() string

GetChaincodeInstallPath returns the path where chaincodes are installed

func (*Store) Initialize Uses

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 Uses

func (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)

ListInstalledChaincodes returns an array with information about the chaincodes installed in the persistence store

func (*Store) Load Uses

func (s *Store) Load(packageID string) ([]byte, error)

Load loads a persisted chaincode install package bytes with the given packageID.

func (*Store) Save Uses

func (s *Store) Save(label string, ccInstallPkg []byte) (string, error)

Save persists chaincode install package bytes. It returns the hash of the chaincode install package

type TarFileStream Uses

type TarFileStream struct {
    TarFile    io.Reader
    FileStream io.Closer
}

func (*TarFileStream) Close Uses

func (tfs *TarFileStream) Close() error

func (*TarFileStream) Read Uses

func (tfs *TarFileStream) Read(p []byte) (int, error)

Directories

PathSynopsis
mockCode generated by counterfeiter.

Package persistence imports 16 packages (graph) and is imported by 13 packages. Updated 2019-11-20. Refresh now. Tools for package owners.