Skip to content

Commit 83f661c

Browse files
committed
[FAB-9755] Remove redundant empty cname check
The getter will panic if the canonical name is not set. Also, standardize "cname" for canonicalName/canName. Change-Id: I1efe6a6a3754616893c1fd308071a70b0a98d176 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent d1dd343 commit 83f661c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

core/chaincode/chaincode_support.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ func (cs *ChaincodeSupport) launchAndWaitForReady(ctx context.Context, cccid *cc
159159
//Stop stops a chaincode if running
160160
func (cs *ChaincodeSupport) Stop(ctx context.Context, cccid *ccprovider.CCContext, cds *pb.ChaincodeDeploymentSpec) error {
161161
cname := cccid.GetCanonicalName()
162-
if cname == "" {
163-
return errors.New("chaincode name not set")
164-
}
165-
166162
defer cs.HandlerRegistry.Deregister(cname)
167163

168164
err := cs.ContainerRuntime.Stop(ctx, cccid, cds)
@@ -274,14 +270,14 @@ func createCCMessage(typ pb.ChaincodeMessage_Type, cid string, txid string, cMsg
274270
func (cs *ChaincodeSupport) Execute(ctxt context.Context, cccid *ccprovider.CCContext, msg *pb.ChaincodeMessage, timeout time.Duration) (*pb.ChaincodeMessage, error) {
275271
chaincodeLogger.Debugf("Entry")
276272
defer chaincodeLogger.Debugf("Exit")
277-
canName := cccid.GetCanonicalName()
273+
cname := cccid.GetCanonicalName()
278274

279-
chaincodeLogger.Debugf("chaincode canonical name: %s", canName)
275+
chaincodeLogger.Debugf("chaincode canonical name: %s", cname)
280276
//we expect the chaincode to be running... sanity check
281-
handler := cs.HandlerRegistry.Handler(canName)
277+
handler := cs.HandlerRegistry.Handler(cname)
282278
if handler == nil {
283-
chaincodeLogger.Debugf("cannot execute-chaincode is not running: %s", canName)
284-
return nil, errors.Errorf("cannot execute transaction for %s", canName)
279+
chaincodeLogger.Debugf("cannot execute-chaincode is not running: %s", cname)
280+
return nil, errors.Errorf("cannot execute transaction for %s", cname)
285281
}
286282

287283
ccresp, err := handler.Execute(ctxt, cccid, msg, timeout)

0 commit comments

Comments
 (0)