cceventmgmt

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: Apache-2.0 Imports: 9 Imported by: 1,311

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize()

Initialize initializes event mgmt

Types

type ChaincodeDefinition

type ChaincodeDefinition struct {
	Name    string
	Hash    []byte
	Version string
}

ChaincodeDefinition captures the info about chaincode

func (*ChaincodeDefinition) String

func (cdef *ChaincodeDefinition) String() string

type ChaincodeInfoProvider

type ChaincodeInfoProvider interface {
	// IsChaincodeDeployed returns true if the given chaincode is deployed on the given channel.
	// TODO, the syscc provider should probably be part of the impl struct, but because of the
	// current complexities of our initialization, it is much easier to pass as a parameter.
	IsChaincodeDeployed(chainid string, chaincodeDefinition *ChaincodeDefinition, sccp sysccprovider.SystemChaincodeProvider) (bool, 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 {
}

KVLedgerLSCCStateListener listens for state changes on 'lscc' namespace

func (*KVLedgerLSCCStateListener) HandleStateUpdates

func (listener *KVLedgerLSCCStateListener) HandleStateUpdates(channelName string, stateUpdates ledger.StateUpdates, committingBlockNum uint64) error

HandleStateUpdates iterates over key-values being written in the 'lscc' namespace (which indicates 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 added in v1.2.0

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

InterestedInNamespaces implements function from interface `ledger.StateListener`

func (*KVLedgerLSCCStateListener) StateCommitDone added in v1.2.0

func (listener *KVLedgerLSCCStateListener) StateCommitDone(channelName string)

StateCommitDone implements function from interface `ledger.StateListener` as a NOOP

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 added in v1.2.0

func (m *Mgr) ChaincodeDeployDone(chainid string)

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

func (*Mgr) ChaincodeInstallDone added in v1.2.0

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, sccp sysccprovider.SystemChaincodeProvider) 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