@@ -31,8 +31,7 @@ type Runtime interface {
3131
3232// Launcher is used to launch chaincode runtimes.
3333type Launcher interface {
34- Launch (context context.Context , channelID , chaincodeName string ) error
35- LaunchInit (context context.Context , ccci * lifecycle.ChaincodeContainerInfo ) error
34+ Launch (context context.Context , ccci * lifecycle.ChaincodeContainerInfo ) error
3635}
3736
3837// Lifecycle provides a way to retrieve chaincode definitions and the packages necessary to run them
@@ -61,6 +60,7 @@ type ChaincodeSupport struct {
6160 HandlerRegistry * HandlerRegistry
6261 Launcher Launcher
6362 sccp sysccprovider.SystemChaincodeProvider
63+ Lifecycle Lifecycle
6464}
6565
6666// NewChaincodeSupport creates a new ChaincodeSupport instance.
@@ -91,6 +91,11 @@ func NewChaincodeSupport(
9191 certGenerator = nil
9292 }
9393
94+ cs .Lifecycle = & lifecycle.Lifecycle {
95+ Executor : cs ,
96+ InstantiatedChaincodeStore : chaincodeStore ,
97+ }
98+
9499 cs .Runtime = & ContainerRuntime {
95100 CertGenerator : certGenerator ,
96101 Processor : processor ,
@@ -108,11 +113,7 @@ func NewChaincodeSupport(
108113 Runtime : cs .Runtime ,
109114 Registry : cs .HandlerRegistry ,
110115 PackageProvider : packageProvider ,
111- Lifecycle : & lifecycle.Lifecycle {
112- Executor : cs ,
113- InstantiatedChaincodeStore : chaincodeStore ,
114- },
115- StartupTimeout : config .StartupTimeout ,
116+ StartupTimeout : config .StartupTimeout ,
116117 }
117118
118119 return cs
@@ -132,7 +133,7 @@ func (cs *ChaincodeSupport) LaunchInit(ctx context.Context, cccid *ccprovider.CC
132133 ccci := lifecycle .DeploymentSpecToChaincodeContainerInfo (spec )
133134 ccci .Version = cccid .Version
134135
135- return cs .Launcher .LaunchInit (ctx , ccci )
136+ return cs .Launcher .Launch (ctx , ccci )
136137}
137138
138139// Launch starts executing chaincode if it is not already running. This method
@@ -155,8 +156,14 @@ func (cs *ChaincodeSupport) Launch(ctx context.Context, cccid *ccprovider.CCCont
155156 // used to support system chaincode. It should really be instantiated with the
156157 // appropriate reference to ChaincodeSupport.
157158 ctx = context .WithValue (ctx , ccintf .GetCCHandlerKey (), cs )
159+ chaincodeName := spec .GetChaincodeSpec ().Name ()
160+
161+ ccci , err := cs .Lifecycle .ChaincodeContainerInfo (cccid .ChainID , chaincodeName )
162+ if err != nil {
163+ return errors .Wrapf (err , "[channel %s] failed to get chaincode container info for %s" , cccid .ChainID , chaincodeName )
164+ }
158165
159- return cs .Launcher .Launch (ctx , cccid . ChainID , spec . ChaincodeSpec . ChaincodeId . Name )
166+ return cs .Launcher .Launch (ctx , ccci )
160167}
161168
162169// Stop stops a chaincode if running.
0 commit comments