lifecycle

package
v0.0.0-...-8a0a438 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//InstalledChaincodeFuncName is the chaincode function name used to install a chaincode
	InstallChaincodeFuncName = "InstallChaincode"

	// QueryInstalledChaincodeFuncName is the chaincode function name used to query an installed chaincode
	QueryInstalledChaincodeFuncName = "QueryInstalledChaincode"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChaincodeStore

type ChaincodeStore interface {
	Save(name, version string, ccInstallPkg []byte) (hash []byte, err error)
	RetrieveHash(name, version string) (hash []byte, err error)
}

ChaincodeStore provides a way to persist chaincodes

type Lifecycle

type Lifecycle struct {
	ChaincodeStore ChaincodeStore
	PackageParser  PackageParser
}

Lifecycle implements the lifecycle operations which are invoked by the SCC as well as internally

func (*Lifecycle) InstallChaincode

func (l *Lifecycle) InstallChaincode(name, version string, chaincodeInstallPackage []byte) ([]byte, error)

InstallChaincode installs a given chaincode to the peer's chaincode store. It returns the hash to reference the chaincode by or an error on failure.

func (*Lifecycle) QueryInstalledChaincode

func (l *Lifecycle) QueryInstalledChaincode(name, version string) ([]byte, error)

QueryInstalledChaincode returns the hash of an installed chaincode of a given name and version.

type PackageParser

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

type Protobuf

type Protobuf interface {
	Marshal(msg proto.Message) (marshaled []byte, err error)
	Unmarshal(marshaled []byte, msg proto.Message) error
}

Protobuf defines the subset of protobuf lifecycle needs and allows for injection of mocked marshaling errors.

type ProtobufImpl

type ProtobufImpl struct{}

ProtobufImpl is the standard implementation to use for Protobuf

func (ProtobufImpl) Marshal

func (p ProtobufImpl) Marshal(msg proto.Message) ([]byte, error)

Marshal passes through to proto.Marshal

func (ProtobufImpl) Unmarshal

func (p ProtobufImpl) Unmarshal(marshaled []byte, msg proto.Message) error

Unmarshal passes through to proto.Unmarshal

type SCC

type SCC struct {
	Protobuf  Protobuf
	Functions SCCFunctions
}

SCC implements the required methods to satisfy the chaincode interface. It routes the invocation calls to the backing implementations.

func (*SCC) Chaincode

func (scc *SCC) Chaincode() shim.Chaincode

Chaincode returns a reference to itself

func (*SCC) Enabled

func (scc *SCC) Enabled() bool

Enabled returns true

func (*SCC) Init

func (scc *SCC) Init(stub shim.ChaincodeStubInterface) pb.Response

Init is mostly useless for system chaincodes and always returns success

func (*SCC) InitArgs

func (scc *SCC) InitArgs() [][]byte

InitArgs returns nil

func (*SCC) InvokableCC2CC

func (scc *SCC) InvokableCC2CC() bool

InvokableCC2CC returns true

func (*SCC) InvokableExternal

func (scc *SCC) InvokableExternal() bool

InvokableExternal returns true

func (*SCC) Invoke

func (scc *SCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response

Invoke takes chaincode invocation arguments and routes them to the correct underlying lifecycle operation. All functions take a single argument of type marshaled lb.<FunctionName>Args and return a marshaled lb.<FunctionName>Result

func (*SCC) Name

func (scc *SCC) Name() string

Name returns "+lifecycle"

func (*SCC) Path

func (scc *SCC) Path() string

Path returns "github.com/hyperledger/fabric/core/chaincode/lifecycle"

type SCCFunctions

type SCCFunctions interface {
	// InstallChaincode persists a chaincode definition to disk
	InstallChaincode(name, version string, chaincodePackage []byte) (hash []byte, err error)

	// QueryInstalledChaincode returns the hash for a given name and version of an installed chaincode
	QueryInstalledChaincode(name, version string) (hash []byte, err error)
}

SCCFunctions provides a backing implementation with concrete arguments for each of the SCC functions

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