{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cceventmgmt\n\n## Functions\n\n```go\nfunc Initialize(ccInfoProvider ChaincodeInfoProvider)\n```\nInitialize initializes event mgmt\n\n## Types\n\n```go\ntype ChaincodeDefinition struct {\n\tName              string\n\tHash              []byte\n\tVersion           string\n\tCollectionConfigs *common.CollectionConfigPackage\n}\n```\nChaincodeDefinition captures the info about chaincode\n\n```go\nfunc (cdef *ChaincodeDefinition) String() string\n```\n\n```go\ntype ChaincodeInfoProvider interface {\n\t// GetDeployedChaincodeInfo retrieves the details about the deployed chaincode.\n\t// This function is expected to return nil, if the chaincode with the given name is not deployed\n\t// or the version or hash of the deployed chaincode does not match with the given version and hash\n\tGetDeployedChaincodeInfo(chainid string, chaincodeDefinition *ChaincodeDefinition) (*ledger.DeployedChaincodeInfo, error)\n\t// RetrieveChaincodeArtifacts checks if the given chaincode is installed on the peer and if yes,\n\t// it extracts the state db specific artifacts from the chaincode package tarball\n\tRetrieveChaincodeArtifacts(chaincodeDefinition *ChaincodeDefinition) (installed bool, dbArtifactsTar []byte, err error)\n}\n```\nChaincodeInfoProvider interface enables event mgr to retrieve chaincode info for a given chaincode\n\n```go\ntype ChaincodeLifecycleEventListener interface {\n\t// HandleChaincodeDeploy is invoked when chaincode installed + defined becomes true.\n\t// The expected usage are to creates all the necessary statedb structures (such as indexes) and update\n\t// service discovery info. This function is invoked immediately before the committing the state changes\n\t// that contain chaincode definition or when a chaincode install happens\n\tHandleChaincodeDeploy(chaincodeDefinition *ChaincodeDefinition, dbArtifactsTar []byte) error\n\t// ChaincodeDeployDone is invoked after the chaincode deployment is finished - `succeeded` indicates\n\t// whether the deploy finished successfully\n\tChaincodeDeployDone(succeeded bool)\n}\n```\nChaincodeLifecycleEventListener 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\n\n```go\ntype KVLedgerLSCCStateListener struct {\n\tDeployedChaincodeInfoProvider ledger.DeployedChaincodeInfoProvider\n}\n```\nKVLedgerLSCCStateListener listens for state changes for chaincode lifecycle\n\n```go\nfunc (listener *KVLedgerLSCCStateListener) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error\n```\nHandleStateUpdates 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)\n\n```go\nfunc (listener *KVLedgerLSCCStateListener) InterestedInNamespaces() []string\n```\nInterestedInNamespaces implements function from interface \\`ledger.StateListener\\`\n\n```go\nfunc (listener *KVLedgerLSCCStateListener) StateCommitDone(channelName string)\n```\nStateCommitDone implements function from interface \\`ledger.StateListener\\`\n\n```go\ntype Mgr struct {\n\t// contains filtered or unexported fields\n}\n```\nMgr encapsulate important interactions for events related to the interest of ledger\n\n```go\nfunc GetMgr() *Mgr\n```\nGetMgr returns the reference to singleton event manager\n\n```go\nfunc (m *Mgr) ChaincodeDeployDone(chainid string)\n```\nChaincodeDeployDone is expected to be called when the deploy transaction state is committed\n\n```go\nfunc (m *Mgr) ChaincodeInstallDone(succeeded bool)\n```\nChaincodeInstallDone is expected to get invoked when chaincode install finishes\n\n```go\nfunc (m *Mgr) HandleChaincodeDeploy(chainid string, chaincodeDefinitions []*ChaincodeDefinition) error\n```\nHandleChaincodeDeploy 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\\`\n\n```go\nfunc (m *Mgr) HandleChaincodeInstall(chaincodeDefinition *ChaincodeDefinition, dbArtifacts []byte) error\n```\nHandleChaincodeInstall is expected to get invoked during installation of a chaincode package\n\n```go\nfunc (m *Mgr) Register(ledgerid string, l ChaincodeLifecycleEventListener)\n```\nRegister registers a ChaincodeLifecycleEventListener for given ledgerid Since, \\`Register\\` is expected to be invoked when creating/opening a ledger instance\n\n","path":"github.com/eric-erki/https-hyperledger.org/core/ledger/cceventmgmt","name":"cceventmgmt","synopsis":"","isRedistributable":true}
