Skip to content

Commit

Permalink
[FAB-3154] Fix the renaming of getChaincodeBytes
Browse files Browse the repository at this point in the history
The existing getChaincodeBytes function actually create a deployment
spec, rather than the name implies. This patchset unify those names of
both chaincode spec creation and chaincode deployment spec creation.

https://jira.hyperledger.org/browse/FAB-3154.

Change-Id: I15d783abdb14feb7fb0ee89cadf6512374d07745
Signed-off-by: Baohua Yang <baohyang@cn.ibm.com>
  • Loading branch information
yeasy committed Apr 14, 2017
1 parent e1dc407 commit 8369bd3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions peer/chaincode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func checkSpec(spec *pb.ChaincodeSpec) error {
return platform.ValidateSpec(spec)
}

// getChaincodeBytes get chaincode deployment spec given the chaincode spec
func getChaincodeBytes(spec *pb.ChaincodeSpec, crtPkg bool) (*pb.ChaincodeDeploymentSpec, error) {
// getChaincodeDeploymentSpec get chaincode deployment spec given the chaincode spec
func getChaincodeDeploymentSpec(spec *pb.ChaincodeSpec, crtPkg bool) (*pb.ChaincodeDeploymentSpec, error) {
var codePackageBytes []byte
if chaincode.IsDevMode() == false && crtPkg {
var err error
Expand All @@ -70,7 +70,8 @@ func getChaincodeBytes(spec *pb.ChaincodeSpec, crtPkg bool) (*pb.ChaincodeDeploy
return chaincodeDeploymentSpec, nil
}

func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
// getChaincodeSpec get chaincode spec from the cli cmd pramameters
func getChaincodeSpec(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
spec := &pb.ChaincodeSpec{}
if err := checkChaincodeCmdParams(cmd); err != nil {
return spec, err
Expand All @@ -92,7 +93,7 @@ func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
}

func chaincodeInvokeOrQuery(cmd *cobra.Command, args []string, invoke bool, cf *ChaincodeCmdFactory) (err error) {
spec, err := getChaincodeSpecification(cmd)
spec, err := getChaincodeSpec(cmd)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions peer/chaincode/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ func generateChaincode(cmd *cobra.Command, chaincodeName, chaincodeVersion strin
return nil, fmt.Errorf("chaincode %s:%s exists", chaincodeName, chaincodeVersion)
}

spec, err := getChaincodeSpecification(cmd)
spec, err := getChaincodeSpec(cmd)
if err != nil {
return nil, err
}

cds, err := getChaincodeBytes(spec, true)
cds, err := getChaincodeDeploymentSpec(spec, true)
if err != nil {
return nil, fmt.Errorf("Error getting chaincode code %s: %s", chainFuncName, err)
}
Expand Down
4 changes: 2 additions & 2 deletions peer/chaincode/instantiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ func instantiateCmd(cf *ChaincodeCmdFactory) *cobra.Command {

//instantiate the command via Endorser
func instantiate(cmd *cobra.Command, cf *ChaincodeCmdFactory) (*protcommon.Envelope, error) {
spec, err := getChaincodeSpecification(cmd)
spec, err := getChaincodeSpec(cmd)
if err != nil {
return nil, err
}

cds, err := getChaincodeBytes(spec, false)
cds, err := getChaincodeDeploymentSpec(spec, false)
if err != nil {
return nil, fmt.Errorf("Error getting chaincode code %s: %s", chainFuncName, err)
}
Expand Down
4 changes: 2 additions & 2 deletions peer/chaincode/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const package_desc = "Package the specified chaincode into a deployment spec."
type ccDepSpecFactory func(spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error)

func defaultCDSFactory(spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error) {
return getChaincodeBytes(spec, true)
return getChaincodeDeploymentSpec(spec, true)
}

// deployCmd returns the cobra command for Chaincode Deploy
Expand Down Expand Up @@ -153,7 +153,7 @@ func chaincodePackage(cmd *cobra.Command, args []string, cdsFact ccDepSpecFactor
return err
}
}
spec, err := getChaincodeSpecification(cmd)
spec, err := getChaincodeSpec(cmd)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions peer/chaincode/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func upgradeCmd(cf *ChaincodeCmdFactory) *cobra.Command {

//upgrade the command via Endorser
func upgrade(cmd *cobra.Command, cf *ChaincodeCmdFactory) (*protcommon.Envelope, error) {
spec, err := getChaincodeSpecification(cmd)
spec, err := getChaincodeSpec(cmd)
if err != nil {
return nil, err
}

cds, err := getChaincodeBytes(spec, false)
cds, err := getChaincodeDeploymentSpec(spec, false)
if err != nil {
return nil, fmt.Errorf("Error getting chaincode code %s: %s", chainFuncName, err)
}
Expand Down

0 comments on commit 8369bd3

Please sign in to comment.