persistence

package
v2.0.0-alpha+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ChaincodePackage

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

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

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{}

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 CodePackageNotFoundErr

type CodePackageNotFoundErr struct {
	PackageID persistence.PackageID
}

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 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) 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(filename string, data []byte, perm os.FileMode) error

WriteFile writes a file to the filesystem

type IOReadWriter

type IOReadWriter interface {
	ReadDir(string) ([]os.FileInfo, error)
	ReadFile(string) ([]byte, error)
	Remove(name string) error
	WriteFile(string, []byte, 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 LegacyPackageProvider

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

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

PackageParser provides an implementation of chaincode package parsing

type PackageProvider

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

func (p *PackageProvider) GetChaincodeCodePackage(ccci *ccprovider.ChaincodeContainerInfo) ([]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

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

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

type Store

type Store struct {
	Path       string
	ReadWriter IOReadWriter
}

Store holds the information needed for persisting a chaincode install package

func (*Store) GetChaincodeInstallPath

func (s *Store) GetChaincodeInstallPath() string

GetChaincodeInstallPath returns the path where chaincodes are installed

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

func (s *Store) Load(packageID persistence.PackageID) ([]byte, error)

Load loads a persisted chaincode install package bytes with the given hash and also returns the chaincode metadata (names and versions) of any chaincode installed with a matching hash

func (*Store) Save

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

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

type StorePackageProvider

type StorePackageProvider interface {
	GetChaincodeInstallPath() string
	ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
	Load(packageID persistence.PackageID) ([]byte, error)
}

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

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL