From a4c100c79d22fbb0ad42ab046cba058da9b5328c Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Thu, 4 May 2017 11:25:42 -0400 Subject: [PATCH] [FAB-3665] Update chaincode.executetimeout to duration This CR updates the chaincode execute timeout from an integer to a time duration. This has been done for consistency with other timeouts defined for the peer and orderer. Change-Id: Icd0fba2838703ad10a0a17daeedfd5a48e051f4f Signed-off-by: Will Lahti --- core/chaincode/chaincode_support.go | 12 ++++++------ core/scc/cscc/configure_test.go | 2 +- sampleconfig/core.yaml | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/chaincode/chaincode_support.go b/core/chaincode/chaincode_support.go index 4b3b8f162ed..86d02369a25 100644 --- a/core/chaincode/chaincode_support.go +++ b/core/chaincode/chaincode_support.go @@ -169,16 +169,16 @@ func NewChaincodeSupport(getPeerEndpoint func() (*pb.PeerEndpoint, error), userr theChaincodeSupport.keepalive = time.Duration(t) * time.Second } - //default chaincode execute timeout is 30000ms (30 secs) - execto := 30000 - if eto := viper.GetInt("chaincode.executetimeout"); eto <= 1000 { - chaincodeLogger.Errorf("Invalid execute timeout value %d (should be at least 1000ms) defaulting to %d ms", eto, execto) + //default chaincode execute timeout is 30 secs + execto := time.Duration(30) * time.Second + if eto := viper.GetDuration("chaincode.executetimeout"); eto <= time.Duration(1)*time.Second { + chaincodeLogger.Errorf("Invalid execute timeout value %s (should be at least 1s); defaulting to %s", eto, execto) } else { - chaincodeLogger.Debugf("Setting execute timeout value to %d ms", eto) + chaincodeLogger.Debugf("Setting execute timeout value to %s", eto) execto = eto } - theChaincodeSupport.executetimeout = time.Duration(execto) * time.Millisecond + theChaincodeSupport.executetimeout = execto viper.SetEnvPrefix("CORE") viper.AutomaticEnv() diff --git a/core/scc/cscc/configure_test.go b/core/scc/cscc/configure_test.go index 80dc26c7888..a19491ecc2d 100644 --- a/core/scc/cscc/configure_test.go +++ b/core/scc/cscc/configure_test.go @@ -135,7 +135,7 @@ func TestConfigerInvokeJoinChainCorrectParams(t *testing.T) { sysccprovider.RegisterSystemChaincodeProviderFactory(&scc.MocksccProviderFactory{}) viper.Set("peer.fileSystemPath", "/tmp/hyperledgertest/") - viper.Set("chaincode.executetimeout", "3000") + viper.Set("chaincode.executetimeout", "3s") os.Mkdir("/tmp/hyperledgertest", 0755) peer.MockInitialize() diff --git a/sampleconfig/core.yaml b/sampleconfig/core.yaml index 98dd0b740ee..3a87546e75a 100644 --- a/sampleconfig/core.yaml +++ b/sampleconfig/core.yaml @@ -301,10 +301,10 @@ chaincode: # to come through. 1sec should be plenty for chaincode unit tests startuptimeout: 300s - # timeout in millisecs for invokes and initialize commands + # timeout duration for invokes and initialize commands # this timeout is used by all chaincodes in all the channels including - # system chaincodes. Default is 30000ms (30 seconds) - executetimeout: 30000 + # system chaincodes. Default is 30 seconds + executetimeout: 30s #timeout in millisecs for deploying chaincode from a remote repository. deploytimeout: 30000