fabric: github.com/hyperledger/fabric/core/ledger/cceventmgmt Index | Files

package cceventmgmt

import "github.com/hyperledger/fabric/core/ledger/cceventmgmt"


Package Files

defs.go lsccstate_listener.go mgr.go

func Initialize Uses

func Initialize(ccInfoProvider ChaincodeInfoProvider)

Initialize initializes event mgmt

type ChaincodeDefinition Uses

type ChaincodeDefinition struct {
    Name              string
    Hash              []byte
    Version           string
    CollectionConfigs *peer.CollectionConfigPackage

ChaincodeDefinition captures the info about chaincode

func (*ChaincodeDefinition) String Uses

func (cdef *ChaincodeDefinition) String() string

type ChaincodeInfoProvider Uses

type ChaincodeInfoProvider interface {
    // GetDeployedChaincodeInfo retrieves the details about the deployed chaincode.
    // This function is expected to return nil, if the chaincode with the given name is not deployed
    // or the version or hash of the deployed chaincode does not match with the given version and hash
    GetDeployedChaincodeInfo(chainid string, chaincodeDefinition *ChaincodeDefinition) (*ledger.DeployedChaincodeInfo, error)
    // RetrieveChaincodeArtifacts checks if the given chaincode is installed on the peer and if yes,
    // it extracts the state db specific artifacts from the chaincode package tarball
    RetrieveChaincodeArtifacts(chaincodeDefinition *ChaincodeDefinition) (installed bool, dbArtifactsTar []byte, err error)

ChaincodeInfoProvider interface enables event mgr to retrieve chaincode info for a given chaincode

type ChaincodeLifecycleEventListener Uses

type ChaincodeLifecycleEventListener interface {
    // HandleChaincodeDeploy is invoked when chaincode installed + defined becomes true.
    // The expected usage are to creates all the necessary statedb structures (such as indexes) and update
    // service discovery info. This function is invoked immediately before the committing the state changes
    // that contain chaincode definition or when a chaincode install happens
    HandleChaincodeDeploy(chaincodeDefinition *ChaincodeDefinition, dbArtifactsTar []byte) error
    // ChaincodeDeployDone is invoked after the chaincode deployment is finished - `succeeded` indicates
    // whether the deploy finished successfully
    ChaincodeDeployDone(succeeded bool)

ChaincodeLifecycleEventListener interface enables ledger components (mainly, intended for statedb) to be able to listen to chaincode lifecycle events. 'dbArtifactsTar' represents db specific artifacts (such as index specs) packaged in a tar

type KVLedgerLSCCStateListener Uses

type KVLedgerLSCCStateListener struct {
    DeployedChaincodeInfoProvider ledger.DeployedChaincodeInfoProvider

KVLedgerLSCCStateListener listens for state changes for chaincode lifecycle

func (*KVLedgerLSCCStateListener) HandleStateUpdates Uses

func (listener *KVLedgerLSCCStateListener) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error

HandleStateUpdates uses 'DeployedChaincodeInfoProvider' to findout deployment of a chaincode and invokes `HandleChaincodeDeploy` function on chaincode event manager (which in turn is responsible for creation of statedb artifacts for the chaincode statedata)

func (*KVLedgerLSCCStateListener) Initialize Uses

func (listener *KVLedgerLSCCStateListener) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error

func (*KVLedgerLSCCStateListener) InterestedInNamespaces Uses

func (listener *KVLedgerLSCCStateListener) InterestedInNamespaces() []string

InterestedInNamespaces implements function from interface `ledger.StateListener`

func (*KVLedgerLSCCStateListener) StateCommitDone Uses

func (listener *KVLedgerLSCCStateListener) StateCommitDone(channelName string)

StateCommitDone implements function from interface `ledger.StateListener`

type Mgr Uses

type Mgr struct {
    // contains filtered or unexported fields

Mgr encapsulate important interactions for events related to the interest of ledger

func GetMgr Uses

func GetMgr() *Mgr

GetMgr returns the reference to singleton event manager

func (*Mgr) ChaincodeDeployDone Uses

func (m *Mgr) ChaincodeDeployDone(chainid string)

ChaincodeDeployDone is expected to be called when the deploy transaction state is committed

func (*Mgr) ChaincodeInstallDone Uses

func (m *Mgr) ChaincodeInstallDone(succeeded bool)

ChaincodeInstallDone is expected to get invoked when chaincode install finishes

func (*Mgr) HandleChaincodeDeploy Uses

func (m *Mgr) HandleChaincodeDeploy(chainid string, chaincodeDefinitions []*ChaincodeDefinition) error

HandleChaincodeDeploy is expected to be invoked when a chaincode is deployed via a deploy transaction The `chaincodeDefinitions` parameter contains all the chaincodes deployed in a block We need to store the last received `chaincodeDefinitions` because this function is expected to be invoked after the deploy transactions validation is performed but not committed yet to the ledger. Further, we release the read lock after this function. This leaves a small window when a `chaincode install` can happen before the deploy transaction is committed and hence the function `HandleChaincodeInstall` may miss finding the deployed chaincode. So, in function `HandleChaincodeInstall`, we explicitly check for chaincode deployed in this stored `chaincodeDefinitions`

func (*Mgr) HandleChaincodeInstall Uses

func (m *Mgr) HandleChaincodeInstall(chaincodeDefinition *ChaincodeDefinition, dbArtifacts []byte) error

HandleChaincodeInstall is expected to get invoked during installation of a chaincode package

func (*Mgr) Register Uses

func (m *Mgr) Register(ledgerid string, l ChaincodeLifecycleEventListener)

Register registers a ChaincodeLifecycleEventListener for given ledgerid Since, `Register` is expected to be invoked when creating/opening a ledger instance

Package cceventmgmt imports 6 packages (graph) and is imported by 20 packages. Updated 2019-11-24. Refresh now. Tools for package owners.