Skip to content

Commit

Permalink
FAB-11033 Complete removing spec from Launch
Browse files Browse the repository at this point in the history
This CR completes removing the chaincode spec from all of the launch
related functions.

Change-Id: I10ac1b205f45794dc45dadf4140ec07c7f1e9ca1
Signed-off-by: Jason Yellick <[email protected]>
  • Loading branch information
Jason Yellick committed Jul 16, 2018
1 parent d72773e commit b7157a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
24 changes: 11 additions & 13 deletions core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,25 @@ func NewChaincodeSupport(
// LaunchForInit bypasses getting the chaincode spec from the LSCC table
// as in the case of v1.0-v1.2 lifecycle, the chaincode will not yet be
// defined in the LSCC table
func (cs *ChaincodeSupport) LaunchInit(cccid *ccprovider.CCContext, spec *pb.ChaincodeDeploymentSpec) error {
cname := cccid.GetCanonicalName()
func (cs *ChaincodeSupport) LaunchInit(ccci *ccprovider.ChaincodeContainerInfo) error {
cname := ccci.Name + ":" + ccci.Version
if cs.HandlerRegistry.Handler(cname) != nil {
return nil
}

ccci := ccprovider.DeploymentSpecToChaincodeContainerInfo(spec)
ccci.Version = cccid.Version

return cs.Launcher.Launch(ccci)
}

// Launch starts executing chaincode if it is not already running. This method
// blocks until the peer side handler gets into ready state or encounters a fatal
// error. If the chaincode is already running, it simply returns.
func (cs *ChaincodeSupport) Launch(cccid *ccprovider.CCContext, spec *pb.ChaincodeInvocationSpec) error {
cname := cccid.GetCanonicalName()
func (cs *ChaincodeSupport) Launch(chainID, chaincodeName, chaincodeVersion string) error {
cname := chaincodeName + ":" + chaincodeVersion
if cs.HandlerRegistry.Handler(cname) != nil {
return nil
}

chaincodeName := spec.GetChaincodeSpec().Name()

ccci, err := cs.Lifecycle.ChaincodeContainerInfo(cccid.ChainID, chaincodeName)
ccci, err := cs.Lifecycle.ChaincodeContainerInfo(chainID, chaincodeName)
if err != nil {
// TODO: There has to be a better way to do this...
if cs.UserRunsCC {
Expand All @@ -143,7 +138,7 @@ func (cs *ChaincodeSupport) Launch(cccid *ccprovider.CCContext, spec *pb.Chainco
)
}

return errors.Wrapf(err, "[channel %s] failed to get chaincode container info for %s", cccid.ChainID, chaincodeName)
return errors.Wrapf(err, "[channel %s] failed to get chaincode container info for %s", chainID, cname)
}

return cs.Launcher.Launch(ccci)
Expand Down Expand Up @@ -245,7 +240,10 @@ func processChaincodeExecutionResult(cccid *ccprovider.CCContext, resp *pb.Chain
func (cs *ChaincodeSupport) InvokeInit(ctxt context.Context, cccid *ccprovider.CCContext, spec *pb.ChaincodeDeploymentSpec) (*pb.ChaincodeMessage, error) {
cctyp := pb.ChaincodeMessage_INIT

err := cs.LaunchInit(cccid, spec)
ccci := ccprovider.DeploymentSpecToChaincodeContainerInfo(spec)
ccci.Version = cccid.Version

err := cs.LaunchInit(ccci)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -275,7 +273,7 @@ func (cs *ChaincodeSupport) Invoke(ctxt context.Context, cccid *ccprovider.CCCon
return nil, errors.New("chaincode spec is nil")
}

err := cs.Launch(cccid, spec)
err := cs.Launch(cccid.ChainID, chaincodeSpec.Name(), cccid.Version)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion core/chaincode/chaincode_support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ func initializeCC(t *testing.T, chainID, ccname string, ccSide *mockpeer.MockCCC
},
}

cccid.Version = "1"
execCC(t, ctxt, ccSide, cccid, false, false, done, cis, respSet, chaincodeSupport)

endTx(t, cccid, txsim, cis)
Expand Down

0 comments on commit b7157a4

Please sign in to comment.