Skip to content

Commit

Permalink
Merge "[FAB-1747] Do not stop devmode chaincode after deploy"
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLevi authored and Gerrit Code Review committed Jan 26, 2017
2 parents c8de78f + 4e6359a commit 8aaf377
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 7 additions & 0 deletions core/chaincode/chaincode_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,10 @@ func (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, cccid *C

return ccresp, err
}

// Returns true if the peer was configured with development-mode enabled
func IsDevMode() bool {
mode := viper.GetString("chaincode.mode")

return mode == DevModeUserRunsChaincode
}
8 changes: 6 additions & 2 deletions core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ func (e *Endorser) deploy(ctxt context.Context, cccid *chaincode.CCContext, cds
return fmt.Errorf("%s", err)
}

//stop now that we are done
chaincodeSupport.Stop(ctxt, cccid, cds)
if chaincode.IsDevMode() == false {
//stop now that we are done
chaincodeSupport.Stop(ctxt, cccid, cds)
} else {
endorserLogger.Debug("devmode: skipping stop")
}

return nil
}
Expand Down
4 changes: 1 addition & 3 deletions peer/chaincode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
pb "github.com/hyperledger/fabric/protos/peer"
putils "github.com/hyperledger/fabric/protos/utils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/net/context"
)

Expand All @@ -54,9 +53,8 @@ func checkSpec(spec *pb.ChaincodeSpec) error {

// getChaincodeBytes get chaincode deployment spec given the chaincode spec
func getChaincodeBytes(spec *pb.ChaincodeSpec) (*pb.ChaincodeDeploymentSpec, error) {
mode := viper.GetString("chaincode.mode")
var codePackageBytes []byte
if mode != chaincode.DevModeUserRunsChaincode {
if chaincode.IsDevMode() == false {
var err error
if err = checkSpec(spec); err != nil {
return nil, err
Expand Down
5 changes: 1 addition & 4 deletions peer/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,7 @@ func serve(args []string) error {
//which will be registered only during join phase.
func registerChaincodeSupport(grpcServer *grpc.Server) {
//get user mode
userRunsCC := false
if viper.GetString("chaincode.mode") == chaincode.DevModeUserRunsChaincode {
userRunsCC = true
}
userRunsCC := chaincode.IsDevMode()

//get chaincode startup timeout
tOut, err := strconv.Atoi(viper.GetString("chaincode.startuptimeout"))
Expand Down

0 comments on commit 8aaf377

Please sign in to comment.