Skip to content

Commit

Permalink
Merge "FAB-2524 - instantiate/upgrade should not specify code"
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersingh24 authored and Gerrit Code Review committed Mar 4, 2017
2 parents 5b48469 + 231bfd0 commit a017b4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 7 additions & 5 deletions core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
//build the chaincode
var cID *pb.ChaincodeID
var cMsg *pb.ChaincodeInput
var cLang pb.ChaincodeSpec_Type

var cds *pb.ChaincodeDeploymentSpec
var ci *pb.ChaincodeInvocationSpec
Expand All @@ -479,7 +478,6 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
if cds != nil {
cID = cds.ChaincodeSpec.ChaincodeId
cMsg = cds.ChaincodeSpec.Input
cLang = cds.ChaincodeSpec.Type
} else {
cID = ci.ChaincodeSpec.ChaincodeId
cMsg = ci.ChaincodeSpec.Input
Expand Down Expand Up @@ -536,8 +534,6 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
if err != nil {
return cID, cMsg, fmt.Errorf("failed to unmarshal deployment transactions for %s - %s", canName, err)
}

cLang = cds.ChaincodeSpec.Type
}

//from here on : if we launch the container and get an error, we need to stop the container
Expand All @@ -554,12 +550,18 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
if err != nil {
return cID, cMsg, err
}
cds.CodePackage = cdsfs.CodePackage
//we should use cdsfs completely. It is just a vestige of old protocol that we
//continue to use ChaincodeDeploymentSpec for anything other than Install. In
//particular, instantiate, invoke, upgrade should be using just some form of
//ChaincodeInvocationSpec.
cds = cdsfs
chaincodeLogger.Debugf("launchAndWaitForRegister fetched %d from file system", len(cds.CodePackage), err)
}
}

builder := func() (io.Reader, error) { return platforms.GenerateDockerBuild(cds) }

cLang := cds.ChaincodeSpec.Type
err = chaincodeSupport.launchAndWaitForRegister(context, cccid, cds, cLang, builder)
if err != nil {
chaincodeLogger.Errorf("launchAndWaitForRegister failed %s", err)
Expand Down
12 changes: 8 additions & 4 deletions core/endorser/endorser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ func getUpgradeProposal(cds *pb.ChaincodeDeploymentSpec, chainID string, creator
//getDeployOrUpgradeProposal gets the proposal for the chaincode deploy or upgrade
//the payload is a ChaincodeDeploymentSpec
func getDeployOrUpgradeProposal(cds *pb.ChaincodeDeploymentSpec, chainID string, creator []byte, upgrade bool) (*pb.Proposal, error) {
//we need to save off the chaincode as we have to instantiate with nil CodePackage
var err error
if err = ccprovider.PutChaincodeIntoFS(cds); err != nil {
return nil, err
}

cds.CodePackage = nil

b, err := proto.Marshal(cds)
if err != nil {
return nil, err
Expand All @@ -166,10 +174,6 @@ func getDeployOrUpgradeProposal(cds *pb.ChaincodeDeploymentSpec, chainID string,
return nil, err
}

if err = ccprovider.PutChaincodeIntoFS(cds); err != nil {
return nil, err
}

return prop, nil
}

Expand Down

0 comments on commit a017b4d

Please sign in to comment.