Skip to content

Commit 0b38d05

Browse files
author
Srinivasan Muralidharan
committed
change ctorMsg to input in Chaincode proto
https://jira.hyperledger.org/browse/FAB-1717 Should never have been "ctor". Also opened https://jira.hyperledger.org/browse/FAB-1729 to address BDD changes (more than just ctor changes). Change-Id: Ia4543a2335ee3317b29512a137ff86d566d8aad9 Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent 823aed3 commit 0b38d05

34 files changed

+191
-189
lines changed

bddtests/chaincode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func createChaincodeSpec(ccType string, path string, args [][]byte) *pb.Chaincod
3030
// make chaincode spec for chaincode to be deployed
3131
ccSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[ccType]),
3232
ChaincodeID: &pb.ChaincodeID{Path: path},
33-
CtorMsg: &pb.ChaincodeInput{Args: args}}
33+
Input: &pb.ChaincodeInput{Args: args}}
3434
return ccSpec
3535

3636
}
@@ -47,7 +47,7 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
4747
}
4848
lcChaincodeSpec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG,
4949
ChaincodeID: &pb.ChaincodeID{Name: "lccc"},
50-
CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
50+
Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
5151
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
5252

5353
uuid := createProposalID()

core/chaincode/chaincode_support.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
510510
}
511511
if cds != nil {
512512
cID = cds.ChaincodeSpec.ChaincodeID
513-
cMsg = cds.ChaincodeSpec.CtorMsg
513+
cMsg = cds.ChaincodeSpec.Input
514514
cLang = cds.ChaincodeSpec.Type
515515
initargs = cMsg.Args
516516
} else {
517517
cID = ci.ChaincodeSpec.ChaincodeID
518-
cMsg = ci.ChaincodeSpec.CtorMsg
518+
cMsg = ci.ChaincodeSpec.Input
519519
}
520520

521521
canName := cccid.GetCanonicalName()

core/chaincode/chaincodeexec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
//create a chaincode invocation spec
3030
func createCIS(ccname string, args [][]byte) (*pb.ChaincodeInvocationSpec, error) {
3131
var err error
32-
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: ccname}, CtorMsg: &pb.ChaincodeInput{Args: args}}}
32+
spec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: ccname}, Input: &pb.ChaincodeInput{Args: args}}}
3333
if nil != err {
3434
return nil, err
3535
}

core/chaincode/concurrency_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
5151

5252
args := util.ToChaincodeArgs("init", "")
5353

54-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, CtorMsg: &pb.ChaincodeInput{Args: args}}
54+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
5555

5656
cccid := NewCCContext(chainID, "nkpi", "0", "", false, nil)
5757

@@ -84,7 +84,7 @@ func TestExecuteConcurrentInvokes(t *testing.T) {
8484
args = util.ToChaincodeArgs("get", newkey)
8585
}
8686

87-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, CtorMsg: &pb.ChaincodeInput{Args: args}}
87+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: chaincodeID, Input: &pb.ChaincodeInput{Args: args}}
8888

8989
//start with a new background
9090
_, _, results[qnum], err = invoke(context.Background(), chainID, spec)

core/chaincode/exectransaction_test.go

+23-23
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func getDeployLCCCSpec(chainID string, cds *pb.ChaincodeDeploymentSpec) (*pb.Cha
236236
}
237237

238238
//wrap the deployment in an invocation spec to lccc...
239-
lcccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeID: &pb.ChaincodeID{Name: "lccc"}, CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte(chainID), b}}}}
239+
lcccSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeID: &pb.ChaincodeID{Name: "lccc"}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte(chainID), b}}}}
240240

241241
return lcccSpec, nil
242242
}
@@ -351,7 +351,7 @@ func executeDeployTransaction(t *testing.T, chainID string, name string, url str
351351

352352
f := "init"
353353
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
354-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: name, Path: url}, CtorMsg: &pb.ChaincodeInput{Args: args}}
354+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: name, Path: url}, Input: &pb.ChaincodeInput{Args: args}}
355355

356356
cccid := NewCCContext(chainID, name, "0", "", false, nil)
357357

@@ -378,7 +378,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
378378
f := "init"
379379
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
380380

381-
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}
381+
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
382382

383383
cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)
384384

@@ -399,7 +399,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
399399
f = "init"
400400
args = util.ToChaincodeArgs(f, "sum", "0")
401401

402-
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
402+
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
403403

404404
cccid2 := NewCCContext(chainID, "example05", "0", "", false, nil)
405405

@@ -417,7 +417,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
417417
f = "invoke"
418418
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
419419

420-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
420+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
421421
// Invoke chaincode
422422
var retVal []byte
423423
_, _, retVal, err = invoke(ctxt, chainID, spec2)
@@ -440,7 +440,7 @@ func chaincodeQueryChaincode(chainID string, user string) error {
440440
f = "query"
441441
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
442442

443-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
443+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
444444
// Invoke chaincode
445445
_, _, retVal, err = invoke(ctxt, chainID, spec2)
446446

@@ -539,7 +539,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *CCContext, cID *pb.
539539

540540
f := "init"
541541
argsDeploy := util.ToChaincodeArgs(f, "a", "100", "b", "200")
542-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: argsDeploy}}
542+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: argsDeploy}}
543543
_, err := deploy(ctxt, cccid, spec)
544544
chaincodeID := spec.ChaincodeID.Name
545545
if err != nil {
@@ -561,7 +561,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *CCContext, cID *pb.
561561

562562
f = "invoke"
563563
invokeArgs := append([]string{f}, args...)
564-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(invokeArgs...)}}
564+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(invokeArgs...)}}
565565
_, uuid, _, err := invoke(ctxt, cccid.ChainID, spec)
566566
if err != nil {
567567
return fmt.Errorf("Error invoking <%s>: %s", cccid.Name, err)
@@ -576,7 +576,7 @@ func invokeExample02Transaction(ctxt context.Context, cccid *CCContext, cID *pb.
576576
// Test for delete state
577577
f = "delete"
578578
delArgs := util.ToChaincodeArgs(f, "a")
579-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: delArgs}}
579+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: delArgs}}
580580
_, uuid, _, err = invoke(ctxt, cccid.ChainID, spec)
581581
if err != nil {
582582
return fmt.Errorf("Error deleting state in <%s>: %s", cccid.Name, err)
@@ -687,7 +687,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
687687
f := "init"
688688
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
689689

690-
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}
690+
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
691691

692692
cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)
693693

@@ -711,7 +711,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
711711
f = "init"
712712
args = util.ToChaincodeArgs(f, "e", "0")
713713

714-
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
714+
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
715715

716716
cccid2 := NewCCContext(chainID, "example04", "0", "", false, nil)
717717

@@ -733,7 +733,7 @@ func chaincodeInvokeChaincode(t *testing.T, chainID string, user string) (err er
733733
cid := spec1.ChaincodeID.Name
734734
args = util.ToChaincodeArgs(f, cid, "e", "1")
735735

736-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
736+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
737737
// Invoke chaincode
738738
var uuid string
739739
_, uuid, _, err = invoke(ctxt, chainID, spec2)
@@ -786,7 +786,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
786786
f := "init"
787787
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
788788

789-
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}
789+
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
790790

791791
cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)
792792

@@ -808,7 +808,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
808808
f = "init"
809809
args = util.ToChaincodeArgs(f)
810810

811-
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
811+
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
812812

813813
cccid2 := NewCCContext(chainID, "pthru", "0", "", false, nil)
814814

@@ -828,7 +828,7 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
828828
f = chaincodeID1
829829
args = util.ToChaincodeArgs(f, "invoke", "a")
830830

831-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
831+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
832832
// Invoke chaincode
833833
_, _, _, err = invoke(ctxt, chainID, spec2)
834834

@@ -875,7 +875,7 @@ func TestRangeQuery(t *testing.T) {
875875
f := "init"
876876
args := util.ToChaincodeArgs(f)
877877

878-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}}
878+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
879879

880880
cccid := NewCCContext(chainID, "tmap", "0", "", false, nil)
881881

@@ -892,7 +892,7 @@ func TestRangeQuery(t *testing.T) {
892892
f = "keys"
893893
args = util.ToChaincodeArgs(f)
894894

895-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}}
895+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
896896
_, _, _, err = invoke(ctxt, chainID, spec)
897897

898898
if err != nil {
@@ -921,7 +921,7 @@ func TestGetEvent(t *testing.T) {
921921

922922
cID := &pb.ChaincodeID{Name: "esender", Path: url}
923923
f := "init"
924-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}}
924+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs(f)}}
925925

926926
cccid := NewCCContext(chainID, "esender", "0", "", false, nil)
927927

@@ -938,7 +938,7 @@ func TestGetEvent(t *testing.T) {
938938

939939
args := util.ToChaincodeArgs("invoke", "i", "am", "satoshi")
940940

941-
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, CtorMsg: &pb.ChaincodeInput{Args: args}}
941+
spec = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID, Input: &pb.ChaincodeInput{Args: args}}
942942

943943
var ccevt *pb.ChaincodeEvent
944944
ccevt, _, _, err = invoke(ctxt, chainID, spec)
@@ -990,7 +990,7 @@ func TestChaincodeQueryChaincodeUsingInvoke(t *testing.T) {
990990
f := "init"
991991
args := util.ToChaincodeArgs(f, "a", "100", "b", "200")
992992

993-
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, CtorMsg: &pb.ChaincodeInput{Args: args}}
993+
spec1 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID1, Input: &pb.ChaincodeInput{Args: args}}
994994

995995
cccid1 := NewCCContext(chainID, "example02", "0", "", false, nil)
996996

@@ -1012,7 +1012,7 @@ func TestChaincodeQueryChaincodeUsingInvoke(t *testing.T) {
10121012
f = "init"
10131013
args = util.ToChaincodeArgs(f, "sum", "0")
10141014

1015-
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
1015+
spec2 := &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
10161016

10171017
cccid2 := NewCCContext(chainID, "example05", "0", "", false, nil)
10181018

@@ -1032,7 +1032,7 @@ func TestChaincodeQueryChaincodeUsingInvoke(t *testing.T) {
10321032
f = "invoke"
10331033
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
10341034

1035-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
1035+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
10361036
// Invoke chaincode
10371037
var retVal []byte
10381038
_, _, retVal, err = invoke(ctxt, chainID, spec2)
@@ -1059,7 +1059,7 @@ func TestChaincodeQueryChaincodeUsingInvoke(t *testing.T) {
10591059
f = "query"
10601060
args = util.ToChaincodeArgs(f, chaincodeID1, "sum")
10611061

1062-
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, CtorMsg: &pb.ChaincodeInput{Args: args}}
1062+
spec2 = &pb.ChaincodeSpec{Type: 1, ChaincodeID: cID2, Input: &pb.ChaincodeInput{Args: args}}
10631063
// Invoke chaincode
10641064
_, _, retVal, err = invoke(ctxt, chainID, spec2)
10651065

core/chaincode/lccc_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func register(stub *shim.MockStub, ccname string) error {
3535
}
3636

3737
func constructDeploymentSpec(name string, path string, initArgs [][]byte) (*pb.ChaincodeDeploymentSpec, error) {
38-
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: name, Path: path}, CtorMsg: &pb.ChaincodeInput{Args: initArgs}}
38+
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeID: &pb.ChaincodeID{Name: name, Path: path}, Input: &pb.ChaincodeInput{Args: initArgs}}
3939
codePackageBytes, err := container.GetChaincodePackageBytes(spec)
4040
if err != nil {
4141
return nil, err

core/chaincode/platforms/car/hash.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
//with the same (name, ctor, args)
3737
func generateHashcode(spec *pb.ChaincodeSpec, path string) (string, error) {
3838

39-
ctor := spec.CtorMsg
39+
ctor := spec.Input
4040
if ctor == nil || len(ctor.Args) == 0 {
4141
return "", errors.New("Cannot generate hashcode from empty ctor")
4242
}

core/chaincode/platforms/car/test/car_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func TestMain(m *testing.M) {
3232
}
3333

3434
func TestCar_BuildImage(t *testing.T) {
35+
//Skipping the test till chaintool is fixed for changint CtorMsg to Input
36+
t.Skip()
3537
vm, err := container.NewVM()
3638

3739
if err != nil {
@@ -46,7 +48,7 @@ func TestCar_BuildImage(t *testing.T) {
4648
}
4749

4850
chaincodePath := cwd + "/org.hyperledger.chaincode.example02-0.1-SNAPSHOT.car"
49-
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
51+
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_CAR, ChaincodeID: &pb.ChaincodeID{Name: "cartest", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
5052
if _, err := vm.BuildChaincodeContainer(spec); err != nil {
5153
t.Error(err)
5254
}

core/chaincode/platforms/golang/hash.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func getCodeFromFS(path string) (codegopath string, err error) {
140140
//NOTE: for dev mode, user builds and runs chaincode manually. The name provided
141141
//by the user is equivalent to the path. This method will treat the name
142142
//as codebytes and compute the hash from it. ie, user cannot run the chaincode
143-
//with the same (name, ctor, args)
143+
//with the same (name, input, args)
144144
func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, error) {
145145
if spec == nil {
146146
return "", errors.New("Cannot collect files from nil spec")
@@ -151,9 +151,9 @@ func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, erro
151151
return "", errors.New("Cannot collect files from empty chaincode path")
152152
}
153153

154-
ctor := spec.CtorMsg
155-
if ctor == nil || len(ctor.Args) == 0 {
156-
return "", errors.New("Cannot collect files from empty ctor")
154+
input := spec.Input
155+
if input == nil || len(input.Args) == 0 {
156+
return "", errors.New("Cannot collect files from empty input")
157157
}
158158

159159
//code root will point to the directory where the code exists
@@ -193,11 +193,11 @@ func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, erro
193193
if err = ccutil.IsCodeExist(tmppath); err != nil {
194194
return "", fmt.Errorf("code does not exist %s", err)
195195
}
196-
ctorbytes, err := proto.Marshal(ctor)
196+
inputbytes, err := proto.Marshal(input)
197197
if err != nil {
198198
return "", fmt.Errorf("Error marshalling constructor: %s", err)
199199
}
200-
hash := util.GenerateHashFromSignature(actualcodepath, ctorbytes)
200+
hash := util.GenerateHashFromSignature(actualcodepath, inputbytes)
201201

202202
hash, err = ccutil.HashFilesInDir(filepath.Join(codegopath, "src"), actualcodepath, hash, tw)
203203
if err != nil {

core/chaincode/platforms/java/hash.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func getCodeFromHTTP(path string) (codegopath string, err error) {
5959
//NOTE: for dev mode, user builds and runs chaincode manually. The name provided
6060
//by the user is equivalent to the path. This method will treat the name
6161
//as codebytes and compute the hash from it. ie, user cannot run the chaincode
62-
//with the same (name, ctor, args)
62+
//with the same (name, input, args)
6363
func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, error) {
6464
if spec == nil {
6565
return "", errors.New("Cannot collect chaincode files from nil spec")
@@ -70,9 +70,9 @@ func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, erro
7070
return "", errors.New("Cannot collect chaincode files from empty chaincode path")
7171
}
7272

73-
ctor := spec.CtorMsg
74-
if ctor == nil || len(ctor.Args) == 0 {
75-
return "", errors.New("Cannot collect chaincode files from empty ctor")
73+
input := spec.Input
74+
if input == nil || len(input.Args) == 0 {
75+
return "", errors.New("Cannot collect chaincode files from empty input")
7676
}
7777

7878
codepath := chaincodeID.Path
@@ -103,11 +103,11 @@ func collectChaincodeFiles(spec *pb.ChaincodeSpec, tw *tar.Writer) (string, erro
103103
return "", fmt.Errorf("code does not exist %s", err)
104104
}
105105

106-
ctorbytes, err := proto.Marshal(ctor)
106+
inputbytes, err := proto.Marshal(input)
107107
if err != nil {
108108
return "", fmt.Errorf("Error marshalling constructor: %s", err)
109109
}
110-
hash := util.GenerateHashFromSignature(codepath, ctorbytes)
110+
hash := util.GenerateHashFromSignature(codepath, inputbytes)
111111

112112
hash, err = ccutil.HashFilesInDir("", codepath, hash, tw)
113113
if err != nil {

core/chaincode/platforms/java/test/java_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestJava_BuildImage(t *testing.T) {
4242

4343
chaincodePath := "../../../../../examples/chaincode/java/SimpleSample"
4444
//TODO find a better way to launch example java chaincode
45-
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_JAVA, ChaincodeID: &pb.ChaincodeID{Name: "ssample", Path: chaincodePath}, CtorMsg: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
45+
spec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_JAVA, ChaincodeID: &pb.ChaincodeID{Name: "ssample", Path: chaincodePath}, Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("f")}}
4646
if _, err := vm.BuildChaincodeContainer(spec); err != nil {
4747
t.Fail()
4848
t.Log(err)

core/chaincode/shim/handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func (handler *Handler) handleRangeQueryStateClose(id, txid string) (*pb.RangeQu
632632
func (handler *Handler) handleInvokeChaincode(chaincodeName string, args [][]byte, txid string) ([]byte, error) {
633633
chaincodeID := &pb.ChaincodeID{Name: chaincodeName}
634634
input := &pb.ChaincodeInput{Args: args}
635-
payload := &pb.ChaincodeSpec{ChaincodeID: chaincodeID, CtorMsg: input}
635+
payload := &pb.ChaincodeSpec{ChaincodeID: chaincodeID, Input: input}
636636
payloadBytes, err := proto.Marshal(payload)
637637
if err != nil {
638638
return nil, errors.New("Failed to process invoke chaincode request")

0 commit comments

Comments
 (0)