cceventmgmt

package
v0.0.0-...-602d9af Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(ccInfoProvider ChaincodeInfoProvider)

Initialize initializes event mgmt

Types

type ChaincodeDefinition

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

ChaincodeDefinition captures the info about chaincode

func (*ChaincodeDefinition) String

func (cdef *ChaincodeDefinition) String() string

type ChaincodeInfoProvider

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

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

type KVLedgerLSCCStateListener struct {
	DeployedChaincodeInfoProvider ledger.DeployedChaincodeInfoProvider
}

KVLedgerLSCCStateListener listens for state changes for chaincode lifecycle

func (*KVLedgerLSCCStateListener) HandleStateUpdates

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

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

InterestedInNamespaces implements function from interface `ledger.StateListener`

func (*KVLedgerLSCCStateListener) StateCommitDone

func (listener *KVLedgerLSCCStateListener) StateCommitDone(channelName string)

StateCommitDone implements function from interface `ledger.StateListener`

type Mgr

type Mgr struct {
	// contains filtered or unexported fields
}

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

func GetMgr

func GetMgr() *Mgr

GetMgr returns the reference to singleton event manager

func (*Mgr) ChaincodeDeployDone

func (m *Mgr) ChaincodeDeployDone(chainid string)

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

func (*Mgr) ChaincodeInstallDone

func (m *Mgr) ChaincodeInstallDone(succeeded bool)

ChaincodeInstallDone is expected to get invoked when chaincode install finishes

func (*Mgr) HandleChaincodeDeploy

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

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

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

func (*Mgr) Register

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

Jump to

Keyboard shortcuts

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