var ( // Logger is the logging instance for this package. // It's exported because the tests override its backend Logger = flogging.MustGetLogger("discovery.lifecycle") )
func DeployedChaincodes(q Query, filter ChaincodePredicate, loadCollections bool, chaincodes ...string) (chaincode.MetadataSet, error)
DeployedChaincodes retrieves the metadata of the given deployed chaincodes
ChaincodePredicate accepts or rejects chaincode based on its metadata
type ChaincodePredicate func(cc chaincode.Metadata) bool
var ( // AcceptAll returns a predicate that accepts all Metadata AcceptAll ChaincodePredicate = func(cc chaincode.Metadata) bool { return true } )
Enumerate enumerates installed chaincodes
type Enumerate func() ([]chaincode.InstalledChaincode, error)
func (listCCs Enumerate) Enumerate() ([]chaincode.InstalledChaincode, error)
Enumerate enumerates chaincodes
Enumerator enumerates chaincodes
type Enumerator interface { // Enumerate returns the installed chaincodes Enumerate() ([]chaincode.InstalledChaincode, error) }
HandleMetadataUpdate is triggered upon a change in the chaincode lifecycle change
type HandleMetadataUpdate func(channel string, chaincodes chaincode.MetadataSet)
func (mdUpdate HandleMetadataUpdate) LifeCycleChangeListener(channel string, chaincodes chaincode.MetadataSet)
LifeCycleChangeListener runs whenever there is a change to the metadata // of a chaincode in the context of a specific channel
LifeCycleChangeListener runs whenever there is a change to the metadata of a chaincode in the context of a specific channel
type LifeCycleChangeListener interface { LifeCycleChangeListener(channel string, chaincodes chaincode.MetadataSet) }
Lifecycle manages information regarding chaincode lifecycle
type Lifecycle struct { sync.RWMutex // contains filtered or unexported fields }
func NewLifeCycle(installedChaincodes Enumerator) (*Lifecycle, error)
NewLifeCycle creates a new Lifecycle instance
func (lc *Lifecycle) AddListener(listener LifeCycleChangeListener)
AddListener registers the given listener to be triggered upon a lifecycle change
func (lc *Lifecycle) Metadata(channel string, cc string, collections bool) *chaincode.Metadata
Metadata returns the metadata of the chaincode on the given channel, or nil if not found or an error occurred at retrieving it
func (lc *Lifecycle) NewChannelSubscription(channel string, queryCreator QueryCreator) (*Subscription, error)
NewChannelSubscription subscribes to a channel
Query queries the state
type Query interface { // GetState gets the value for given namespace and key. For a chaincode, the namespace corresponds to the chaincodeId GetState(namespace string, key string) ([]byte, error) // Done releases resources occupied by the QueryExecutor Done() }
QueryCreator creates queries
type QueryCreator interface { // NewQuery creates a new Query, or error on failure NewQuery() (Query, error) }
QueryCreatorFunc creates a new query
type QueryCreatorFunc func() (Query, error)
func (qc QueryCreatorFunc) NewQuery() (Query, error)
NewQuery creates a new Query, or error on failure
Subscription channels information flow about a specific channel into the Lifecycle
type Subscription struct { sync.Mutex // contains filtered or unexported fields }
func (sub *Subscription) ChaincodeDeployDone(succeeded bool)
ChaincodeDeployDone gets invoked when the chaincode deploy transaction or chaincode install (the context in which the above function was invoked)
func (sub *Subscription) HandleChaincodeDeploy(chaincodeDefinition *cceventmgmt.ChaincodeDefinition, dbArtifactsTar []byte) error
HandleChaincodeDeploy is expected to be invoked when a chaincode is deployed via a deploy transaction and the chaicndoe was already installed on the peer. This also gets invoked when an already deployed chaincode is installed on the peer