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 package_provider.go persistence.go

Constants

const (
    ChaincodePackageMetadataFile = "Chaincode-Package-Metadata.json"
)

type ChaincodeMetadata Uses

type ChaincodeMetadata struct {
    Name    string `json:"Name"`
    Version string `json:"Version"`
}

ChaincodeMetadata holds the name and version of a chaincode

type ChaincodePackage Uses

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

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

type ChaincodePackageMetadata Uses

type ChaincodePackageMetadata struct {
    Type string `json:"Type"`
    Path string `json:"Path"`
}

ChaincodePackageMetadata contains the information necessary to understand the embedded code package.

type ChaincodePackageParser Uses

type ChaincodePackageParser struct{}

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 CodePackageNotFoundErr Uses

type CodePackageNotFoundErr struct {
    Name    string
    Version 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 FilesystemIO Uses

type FilesystemIO struct {
}

FilesystemIO is the production implementation of the IOWriter interface

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) Stat Uses

func (f *FilesystemIO) Stat(name string) (os.FileInfo, error)

Stat checks for existence of the file on the filesystem

func (*FilesystemIO) WriteFile Uses

func (f *FilesystemIO) WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile writes a file to the filesystem

type IOReadWriter Uses

type IOReadWriter interface {
    ReadDir(string) ([]os.FileInfo, error)
    ReadFile(string) ([]byte, error)
    Remove(name string) error
    Stat(string) (os.FileInfo, error)
    WriteFile(string, []byte, os.FileMode) error
}

IOReadWriter defines the interface needed for reading, writing, removing, and checking for existence of a specified file

type LegacyPackageProvider Uses

type LegacyPackageProvider interface {
    GetChaincodeCodePackage(name, version string) (codePackage []byte, err error)
    ListInstalledChaincodes(dir string, de ccprovider.DirEnumerator, ce ccprovider.ChaincodeExtractor) ([]chaincode.InstalledChaincode, error)
}

LegacyPackageProvider is the interface needed to retrieve the code package from a ChaincodeDeploymentSpec

type PackageParser Uses

type PackageParser interface {
    Parse(data []byte) (*ChaincodePackage, error)
}

PackageParser provides an implementation of chaincode package parsing

type PackageProvider Uses

type PackageProvider struct {
    Store    StorePackageProvider
    Parser   PackageParser
    LegacyPP LegacyPackageProvider
}

PackageProvider holds the necessary dependencies to obtain the code package bytes for a chaincode

func (*PackageProvider) GetChaincodeCodePackage Uses

func (p *PackageProvider) GetChaincodeCodePackage(name, version string) ([]byte, error)

GetChaincodeCodePackage 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

func (*PackageProvider) ListInstalledChaincodes Uses

func (p *PackageProvider) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)

ListInstalledChaincodes returns metadata (name, version, and ID) for each chaincode installed on a peer

type Store Uses

type Store struct {
    Path       string
    ReadWriter IOReadWriter
}

Store holds the information needed for persisting a chaincode install package

func (*Store) GetChaincodeInstallPath Uses

func (s *Store) GetChaincodeInstallPath() string

GetChaincodeInstallPath returns the path where chaincodes are installed

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(hash []byte) (ccInstallPkg []byte, name, version string, err error)

Load loads a persisted chaincode install package bytes with the given hash and also returns the name and version

func (*Store) LoadMetadata Uses

func (s *Store) LoadMetadata(path string) (name, version string, err error)

LoadMetadata loads the chaincode metadata stored at the specified path

func (*Store) RetrieveHash Uses

func (s *Store) RetrieveHash(name string, version string) ([]byte, error)

RetrieveHash retrieves the hash of a chaincode install package given the name and version of the chaincode

func (*Store) Save Uses

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

Save persists chaincode install package bytes with the given name and version

type StorePackageProvider Uses

type StorePackageProvider interface {
    GetChaincodeInstallPath() string
    ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
    Load(hash []byte) (codePackage []byte, name, version string, err error)
    RetrieveHash(name, version string) (hash []byte, err error)
}

StorePackageProvider is the interface needed to retrieve the code package from a ChaincodeInstallPackage

Directories

PathSynopsis
mockCode generated by counterfeiter.

Package persistence imports 16 packages (graph) and is imported by 4 packages. Updated 2018-12-21. Refresh now. Tools for package owners.