Skip to content

Commit edf7d7c

Browse files
author
Srinivasan Muralidharan
committed
fab-2177 add install command to lccc
With the new deploy model where the installation is on the file system, the "on peer" install is not quite satisfactory for developers who have to log on to a peer to install before they do anything. This implements a new "install" Invoke command on the LCCC whose only purpose is to put the code on the file system. CLI usage --------- peer chaincode install -n <name> -v <version> -p <path> where the command will install to CORE_PEER_ADDRESS. Change-Id: Ieadd7b9495ddf57ab7099cb788d8b99f4553cdf6 Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent ffe4c91 commit edf7d7c

File tree

10 files changed

+238
-98
lines changed

10 files changed

+238
-98
lines changed

core/chaincode/exectransaction_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ func deploy2(ctx context.Context, cccid *ccprovider.CCContext, chaincodeDeployme
283283
}
284284
}()
285285

286-
if err = ccprovider.PutChaincodeIntoFS(chaincodeDeploymentSpec); err != nil {
287-
return nil, err
288-
}
286+
//ignore existence errors
287+
ccprovider.PutChaincodeIntoFS(chaincodeDeploymentSpec)
289288

290289
sysCCVers := util.GetSysCCVersion()
291290
lcccid := ccprovider.NewCCContext(cccid.ChainID, cis.ChaincodeSpec.ChaincodeId.Name, sysCCVers, uuid, true, nil)

core/common/ccprovider/ccprovider.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,17 @@ func PutChaincodeIntoFS(depSpec *pb.ChaincodeDeploymentSpec) error {
8989
ccname := depSpec.ChaincodeSpec.ChaincodeId.Name
9090
ccversion := depSpec.ChaincodeSpec.ChaincodeId.Version
9191

92+
//return error if chaincode exists
93+
path := fmt.Sprintf("%s/%s.%s", chaincodeInstallPath, ccname, ccversion)
94+
if _, err := os.Stat(path); err == nil {
95+
return fmt.Errorf("chaincode %s exits", path)
96+
}
97+
9298
b, err := proto.Marshal(depSpec)
9399
if err != nil {
94100
return fmt.Errorf("failed to marshal fs deployment spec for %s, %s", ccname, ccversion)
95101
}
96102

97-
path := fmt.Sprintf("%s/%s.%s", chaincodeInstallPath, ccname, ccversion)
98103
if err = ioutil.WriteFile(path, b, 0644); err != nil {
99104
return err
100105
}

core/endorser/endorser.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro
320320
//TODO till we implement global ESCC, CSCC for system chaincodes
321321
//chainless proposals (such as CSCC) don't have to be endorsed
322322
if ischainless {
323-
pResp = &pb.ProposalResponse{Response: &pb.Response{}}
323+
pResp = &pb.ProposalResponse{Response: res}
324324
} else {
325325
pResp, err = e.endorseProposal(ctx, chainID, txid, prop, res, simulationResult, ccevent, hdrExt.PayloadVisibility, hdrExt.ChaincodeId, txsim, cd)
326326
if err != nil {

core/endorser/endorser_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ func TestDeploy(t *testing.T) {
264264
chainID := util.GetTestChainID()
265265
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: "ex01", Path: "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01", Version: "0"}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}}}
266266

267+
defer os.RemoveAll("/tmp/hyperledger/production/chaincodes/ex01.0")
268+
267269
cccid := ccprovider.NewCCContext(chainID, "ex01", "0", "", false, nil)
268270

269271
_, _, err := deploy(endorserServer, chainID, spec, nil)
@@ -283,6 +285,8 @@ func TestRedeploy(t *testing.T) {
283285
//invalid arguments
284286
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: "ex02", Path: "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", Version: "0"}, Input: &pb.ChaincodeInput{Args: [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}}}
285287

288+
defer os.RemoveAll("/tmp/hyperledger/production/chaincodes/ex02.0")
289+
286290
cccid := ccprovider.NewCCContext(chainID, "ex02", "0", "", false, nil)
287291

288292
_, _, err := deploy(endorserServer, chainID, spec, nil)
@@ -293,6 +297,8 @@ func TestRedeploy(t *testing.T) {
293297
return
294298
}
295299

300+
os.RemoveAll("/tmp/hyperledger/production/chaincodes/ex02.0")
301+
296302
//second time should not fail as we are just simulating
297303
_, _, err = deploy(endorserServer, chainID, spec, nil)
298304
if err != nil {
@@ -312,6 +318,8 @@ func TestDeployAndInvoke(t *testing.T) {
312318
url := "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01"
313319
chaincodeID := &pb.ChaincodeID{Path: url, Name: "ex01", Version: "0"}
314320

321+
defer os.RemoveAll("/tmp/hyperledger/production/chaincodes/ex01.0")
322+
315323
args := []string{"10"}
316324

317325
f := "init"
@@ -364,6 +372,9 @@ func TestDeployAndUpgrade(t *testing.T) {
364372
chaincodeID1 := &pb.ChaincodeID{Path: url1, Name: "upgradeex01", Version: "0"}
365373
chaincodeID2 := &pb.ChaincodeID{Path: url2, Name: "upgradeex01", Version: "1"}
366374

375+
defer os.RemoveAll("/tmp/hyperledger/production/chaincodes/upgradeex01.0")
376+
defer os.RemoveAll("/tmp/hyperledger/production/chaincodes/upgradeex01.1")
377+
367378
f := "init"
368379
argsDeploy := util.ToChaincodeArgs(f, "a", "100", "b", "200")
369380
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: chaincodeID1, Input: &pb.ChaincodeInput{Args: argsDeploy}}

core/scc/lccc/lccc.go

+38
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const (
4646

4747
//chaincode lifecyle commands
4848

49+
//INSTALL install command
50+
INSTALL = "install"
51+
4952
//DEPLOY deploy command
5053
DEPLOY = "deploy"
5154

@@ -284,6 +287,29 @@ func (lccc *LifeCycleSysCC) isValidChaincodeName(chaincodename string) bool {
284287
return true
285288
}
286289

290+
//this implements "install" Invoke transaction
291+
func (lccc *LifeCycleSysCC) executeInstall(stub shim.ChaincodeStubInterface, depSpec []byte) error {
292+
cds, err := lccc.getChaincodeDeploymentSpec(depSpec)
293+
294+
if err != nil {
295+
return err
296+
}
297+
298+
if !lccc.isValidChaincodeName(cds.ChaincodeSpec.ChaincodeId.Name) {
299+
return InvalidChaincodeNameErr(cds.ChaincodeSpec.ChaincodeId.Name)
300+
}
301+
302+
if cds.ChaincodeSpec.ChaincodeId.Version == "" {
303+
return EmptyVersionErr(cds.ChaincodeSpec.ChaincodeId.Name)
304+
}
305+
306+
if err = ccprovider.PutChaincodeIntoFS(cds); err != nil {
307+
return fmt.Errorf("Error installing chaincode code %s:%s(%s)", cds.ChaincodeSpec.ChaincodeId.Name, cds.ChaincodeSpec.ChaincodeId.Version, err)
308+
}
309+
310+
return err
311+
}
312+
287313
//this implements "deploy" Invoke transaction
288314
func (lccc *LifeCycleSysCC) executeDeploy(stub shim.ChaincodeStubInterface, chainname string, depSpec []byte, policy []byte, escc []byte, vscc []byte) error {
289315
cds, err := lccc.getChaincodeDeploymentSpec(depSpec)
@@ -395,6 +421,18 @@ func (lccc *LifeCycleSysCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response
395421
function := string(args[0])
396422

397423
switch function {
424+
case INSTALL:
425+
if len(args) < 2 {
426+
return shim.Error(InvalidArgsLenErr(len(args)).Error())
427+
}
428+
429+
depSpec := args[1]
430+
431+
err := lccc.executeInstall(stub, depSpec)
432+
if err != nil {
433+
return shim.Error(err.Error())
434+
}
435+
return shim.Success([]byte("OK"))
398436
case DEPLOY:
399437
if len(args) < 3 || len(args) > 6 {
400438
return shim.Error(InvalidArgsLenErr(len(args)).Error())

core/scc/lccc/lccc_test.go

+86-29
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ func register(stub *shim.MockStub, ccname string) error {
5353
return nil
5454
}
5555

56-
func constructDeploymentSpec(name string, path string, version string, initArgs [][]byte) (*pb.ChaincodeDeploymentSpec, error) {
56+
func constructDeploymentSpec(name string, path string, version string, initArgs [][]byte, createFS bool) (*pb.ChaincodeDeploymentSpec, error) {
5757
spec := &pb.ChaincodeSpec{Type: 1, ChaincodeId: &pb.ChaincodeID{Name: name, Path: path, Version: version}, Input: &pb.ChaincodeInput{Args: initArgs}}
5858

5959
codePackageBytes := []byte(name + path + version)
6060

6161
chaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes}
6262

63-
err := ccprovider.PutChaincodeIntoFS(chaincodeDeploymentSpec)
64-
if err != nil {
65-
return nil, err
63+
if createFS {
64+
err := ccprovider.PutChaincodeIntoFS(chaincodeDeploymentSpec)
65+
if err != nil {
66+
return nil, err
67+
}
6668
}
6769

6870
return chaincodeDeploymentSpec, nil
@@ -78,8 +80,8 @@ func TestDeploy(t *testing.T) {
7880
t.FailNow()
7981
}
8082

81-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
82-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
83+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
84+
defer os.Remove(lccctestpath + "/example02.0")
8385
var b []byte
8486
if b, err = proto.Marshal(cds); err != nil || b == nil {
8587
t.FailNow()
@@ -91,6 +93,55 @@ func TestDeploy(t *testing.T) {
9193
}
9294
}
9395

96+
//TestInstall tests the install function
97+
func TestInstall(t *testing.T) {
98+
scc := new(LifeCycleSysCC)
99+
stub := shim.NewMockStub("lccc", scc)
100+
101+
if res := stub.MockInit("1", nil); res.Status != shim.OK {
102+
fmt.Println("Init failed", string(res.Message))
103+
t.FailNow()
104+
}
105+
106+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, false)
107+
var b []byte
108+
if b, err = proto.Marshal(cds); err != nil || b == nil {
109+
t.FailNow()
110+
}
111+
112+
//constructDeploymentSpec puts the depspec on the FS. This should fail
113+
args := [][]byte{[]byte(INSTALL), b}
114+
defer os.Remove(lccctestpath + "/example02.0")
115+
if res := stub.MockInvoke("1", args); res.Status != shim.OK {
116+
t.FailNow()
117+
}
118+
}
119+
120+
//TestReinstall tests the install function
121+
func TestReinstall(t *testing.T) {
122+
scc := new(LifeCycleSysCC)
123+
stub := shim.NewMockStub("lccc", scc)
124+
125+
if res := stub.MockInit("1", nil); res.Status != shim.OK {
126+
fmt.Println("Init failed", string(res.Message))
127+
t.FailNow()
128+
}
129+
130+
//note that this puts the code on the filesyste....
131+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
132+
defer os.Remove(lccctestpath + "/example02.0")
133+
var b []byte
134+
if b, err = proto.Marshal(cds); err != nil || b == nil {
135+
t.FailNow()
136+
}
137+
138+
//constructDeploymentSpec puts the depspec on the FS. This should fail
139+
args := [][]byte{[]byte(INSTALL), b}
140+
if res := stub.MockInvoke("1", args); res.Status == shim.OK {
141+
t.FailNow()
142+
}
143+
}
144+
94145
//TestInvalidCodeDeploy tests the deploy function with invalid code package
95146
func TestInvalidCodeDeploy(t *testing.T) {
96147
scc := new(LifeCycleSysCC)
@@ -121,8 +172,11 @@ func TestInvalidChaincodeName(t *testing.T) {
121172
t.FailNow()
122173
}
123174

124-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
125-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
175+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
176+
defer os.Remove(lccctestpath + "/example02.0")
177+
if err != nil {
178+
t.FailNow()
179+
}
126180

127181
//change name to empty
128182
cds.ChaincodeSpec.ChaincodeId.Name = ""
@@ -150,8 +204,11 @@ func TestEmptyChaincodeVersion(t *testing.T) {
150204
t.FailNow()
151205
}
152206

153-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
154-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
207+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
208+
defer os.Remove(lccctestpath + "/example02.0")
209+
if err != nil {
210+
t.FailNow()
211+
}
155212

156213
//change version to empty
157214
cds.ChaincodeSpec.ChaincodeId.Version = ""
@@ -179,8 +236,8 @@ func TestRedeploy(t *testing.T) {
179236
t.FailNow()
180237
}
181238

182-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
183-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
239+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
240+
defer os.Remove(lccctestpath + "/example02.0")
184241
var b []byte
185242
if b, err = proto.Marshal(cds); err != nil || b == nil {
186243
t.FailNow()
@@ -209,8 +266,8 @@ func TestCheckCC(t *testing.T) {
209266
t.FailNow()
210267
}
211268

212-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
213-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
269+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
270+
defer os.Remove(lccctestpath + "/example02.0")
214271

215272
var b []byte
216273
if b, err = proto.Marshal(cds); err != nil || b == nil {
@@ -228,7 +285,7 @@ func TestCheckCC(t *testing.T) {
228285
}
229286
}
230287

231-
//TestMultipleDeploy tests deploying multiple chaincodes
288+
//TestMultipleDeploy tests deploying multiple chaincodeschaincodes
232289
func TestMultipleDeploy(t *testing.T) {
233290
scc := new(LifeCycleSysCC)
234291
stub := shim.NewMockStub("lccc", scc)
@@ -239,8 +296,8 @@ func TestMultipleDeploy(t *testing.T) {
239296
}
240297

241298
//deploy 02
242-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
243-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
299+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
300+
defer os.Remove(lccctestpath + "/example02.0")
244301
var b []byte
245302
if b, err = proto.Marshal(cds); err != nil || b == nil {
246303
t.FailNow()
@@ -257,8 +314,8 @@ func TestMultipleDeploy(t *testing.T) {
257314
}
258315

259316
//deploy 01
260-
cds, err = constructDeploymentSpec("example01", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
261-
defer os.Remove(lccctestpath + "/chaincodes/example01.0")
317+
cds, err = constructDeploymentSpec("example01", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
318+
defer os.Remove(lccctestpath + "/example01.0")
262319
if b, err = proto.Marshal(cds); err != nil || b == nil {
263320
t.FailNow()
264321
}
@@ -285,8 +342,8 @@ func TestRetryFailedDeploy(t *testing.T) {
285342
}
286343

287344
//deploy 02
288-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
289-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
345+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
346+
defer os.Remove(lccctestpath + "/example02.0")
290347
var b []byte
291348
if b, err = proto.Marshal(cds); err != nil || b == nil {
292349
t.FailNow()
@@ -328,8 +385,8 @@ func TestUpgrade(t *testing.T) {
328385
t.FailNow()
329386
}
330387

331-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
332-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
388+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
389+
defer os.Remove(lccctestpath + "/example02.0")
333390
var b []byte
334391
if b, err = proto.Marshal(cds); err != nil || b == nil {
335392
t.Fatalf("Marshal DeploymentSpec failed")
@@ -340,8 +397,8 @@ func TestUpgrade(t *testing.T) {
340397
t.Fatalf("Deploy chaincode error: %v", err)
341398
}
342399

343-
newCds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "1", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
344-
defer os.Remove(lccctestpath + "/chaincodes/example02.1")
400+
newCds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "1", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
401+
defer os.Remove(lccctestpath + "/example02.1")
345402
var newb []byte
346403
if newb, err = proto.Marshal(newCds); err != nil || newb == nil {
347404
t.Fatalf("Marshal DeploymentSpec failed")
@@ -370,8 +427,8 @@ func TestUpgradeNonExistChaincode(t *testing.T) {
370427
t.FailNow()
371428
}
372429

373-
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
374-
defer os.Remove(lccctestpath + "/chaincodes/example02.0")
430+
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
431+
defer os.Remove(lccctestpath + "/example02.0")
375432
var b []byte
376433
if b, err = proto.Marshal(cds); err != nil || b == nil {
377434
t.Fatalf("Marshal DeploymentSpec failed")
@@ -382,8 +439,8 @@ func TestUpgradeNonExistChaincode(t *testing.T) {
382439
t.Fatalf("Deploy chaincode error: %s", res.Message)
383440
}
384441

385-
newCds, err := constructDeploymentSpec("example03", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "1", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")})
386-
defer os.Remove(lccctestpath + "/chaincodes/example03.1")
442+
newCds, err := constructDeploymentSpec("example03", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "1", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
443+
defer os.Remove(lccctestpath + "/example03.1")
387444
var newb []byte
388445
if newb, err = proto.Marshal(newCds); err != nil || newb == nil {
389446
t.Fatalf("Marshal DeploymentSpec failed")

core/scc/sysccapi.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,12 @@ func deploySysCC(chainID string, syscc *SystemChaincode) error {
8484
return nil
8585
}
8686

87-
chainless := false
88-
if chainID == "" {
89-
chainless = true
90-
}
91-
9287
var err error
9388

9489
ccprov := ccprovider.GetChaincodeProvider()
9590

9691
ctxt := context.Background()
97-
if !chainless {
92+
if chainID != "" {
9893
lgr := peer.GetLedger(chainID)
9994
if lgr == nil {
10095
panic(fmt.Sprintf("syschain %s start up failure - unexpected nil ledger for channel %s", syscc.Name, chainID))

0 commit comments

Comments
 (0)