...

Package lifecycle

import "github.com/hyperledger/fabric/core/chaincode/lifecycle"
Overview
Index
Subdirectories

Overview ▾

Constants

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"
)

type ChaincodeStore

ChaincodeStore provides a way to persist chaincodes

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

type Lifecycle

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

type Lifecycle struct {
    ChaincodeStore ChaincodeStore
    PackageParser  PackageParser
}

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

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

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

type ProtobufImpl

ProtobufImpl is the standard implementation to use for Protobuf

type ProtobufImpl struct{}

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

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

type SCC struct {
    Protobuf  Protobuf
    Functions SCCFunctions
}

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

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

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

Subdirectories

Name Synopsis
..
mock Code generated by counterfeiter.