Skip to content

Commit 00f083e

Browse files
committed
[FAB-7573] cleanup chaincode support
Allowing concurrent access to invokes and init in 1.0 allowed all the 0.6 separation of Query, Invoke and Init to be vastly simplified (in 0.6 Queries were allowed concurrent access but not others). This also implied that the FSM can be removed completely which was done in FAB-5424. This task completes the work with the following change names of functions to not have "FSM" flavor (they now have "handler" flavor) in core/chaincode/handler.go . chaincode and peer calls driven by function handlers . comment and sundry cleanup . This was tested as follows peer and shim chaincode UT . destructive testing by killing peer and chaincode at different points of the lifecycle . running against a java chaincode to prove the two sides are independent and shims can be worked upon independent of peer chaincode support side Change-Id: I16e59eb2c77e6cc8f0bcfafccb0ae7b220c7317e Signed-off-by: Srinivasan Muralidharan <srinivasan.muralidharan99@gmail.com>
1 parent 47264ca commit 00f083e

File tree

3 files changed

+179
-262
lines changed

3 files changed

+179
-262
lines changed

core/chaincode/chaincode_support.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/hyperledger/fabric/common/flogging"
3131
"github.com/hyperledger/fabric/core/chaincode/accesscontrol"
3232
"github.com/hyperledger/fabric/core/chaincode/platforms"
33-
"github.com/hyperledger/fabric/core/chaincode/shim"
3433
"github.com/hyperledger/fabric/core/common/ccprovider"
3534
"github.com/hyperledger/fabric/core/config"
3635
"github.com/hyperledger/fabric/core/container"
@@ -335,17 +334,14 @@ func (chaincodeSupport *ChaincodeSupport) sendReady(context context.Context, ccc
335334
if notfy != nil {
336335
select {
337336
case ccMsg := <-notfy:
338-
if ccMsg.Type == pb.ChaincodeMessage_ERROR {
337+
switch ccMsg.Type {
338+
case pb.ChaincodeMessage_ERROR:
339339
err = errors.Errorf("error initializing container %s: %s", canName, string(ccMsg.Payload))
340-
}
341-
if ccMsg.Type == pb.ChaincodeMessage_COMPLETED {
342-
res := &pb.Response{}
343-
_ = proto.Unmarshal(ccMsg.Payload, res)
344-
if res.Status != shim.OK {
345-
err = errors.Errorf("error initializing container %s: %s", canName, string(res.Message))
346-
}
347-
// TODO
348-
// return res so that endorser can anylyze it.
340+
case pb.ChaincodeMessage_READY:
341+
chaincodeLogger.Infof("chaincode %s ready to accept requests", canName)
342+
default:
343+
//by construction, we cannot (should not) get anything other than ERROR or READY
344+
panic(fmt.Sprintf("Invalid ready message %+v", ccMsg))
349345
}
350346
case <-time.After(timeout):
351347
err = errors.New("timeout expired while executing send init message")
@@ -656,14 +652,9 @@ func (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, cccid
656652
chaincodeLogger.Debugf("%+v", err)
657653
return cID, cMsg, err
658654
}
659-
if chrte.handler.isRunning() {
660-
if chaincodeLogger.IsEnabledFor(logging.DEBUG) {
661-
chaincodeLogger.Debugf("chaincode is running(no need to launch) : %s", canName)
662-
}
663-
chaincodeSupport.runningChaincodes.Unlock()
664-
return cID, cMsg, nil
665-
}
666-
chaincodeLogger.Debugf("Container not in READY state(%s)...send init/ready", chrte.handler.state)
655+
chaincodeLogger.Debugf("chaincode is running(no need to launch) : %s", canName)
656+
chaincodeSupport.runningChaincodes.Unlock()
657+
return cID, cMsg, nil
667658
} else {
668659
//chaincode is not up... but is the launch process underway? this is
669660
//strictly not necessary as the actual launch process will catch this

0 commit comments

Comments
 (0)