通过nodeSDK实例化chainCode遭遇错误合集

1、cannot find package

2018-09-27 03:59:09.586 UTC [chaincode-platform] func1 -> ERRO 071 Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package svnprojectsecdspaysourcecodeecdspay-baaschaincodeecdspay: cannot find package "svnprojectsecdspaysourcecodeecdspay-baaschaincodeecdspay" in any of:
	/opt/go/src/svnprojectsecdspaysourcecodeecdspay-baaschaincodeecdspay (from $GOROOT)
	/chaincode/input/src/svnprojectsecdspaysourcecodeecdspay-baaschaincodeecdspay (from $GOPATH)
	/opt/gopath/src/svnprojectsecdspaysourcecodeecdspay-baaschaincodeecdspay

解析:这种情况是在chain code install时,传入的path使用了windows的分隔符 '\\' fabric安装chain code时会将其保存至特定位置,并且使用传入的path作为路径的组成部分,所以只能使用 ‘/’。

2、You are attempting to perform an action other than Deploy on Chaincode that is not ready and you are in developer mode. Did you forget to Deploy your chaincode?

源码参考:

1、出错判断

// TODO: There has to be a better way to do this...
	if cs.UserRunsCC && !cccid.Syscc {
		chaincodeLogger.Error(
			"You are attempting to perform an action other than Deploy on Chaincode that is not ready and you are in developer mode. Did you forget to Deploy your chaincode?",
		)
	}

2、UserRunsCC 取值

//NOTE - when we implement JOIN we will no longer pass the chainID as param
//The chaincode support will come up without registering system chaincodes
//which will be registered only during join phase.
func registerChaincodeSupport(grpcServer *comm.GRPCServer, ccEndpoint string, ca tlsgen.CA, aclProvider aclmgmt.ACLProvider) (*chaincode.ChaincodeSupport, ccprovider.ChaincodeProvider, *scc.Provider) {
	//get user mode
	userRunsCC := chaincode.IsDevMode()
	tlsEnabled := viper.GetBool("peer.tls.enabled")
// IsDevMode returns true if the peer was configured with development-mode
// enabled.
func IsDevMode() bool {
	mode := viper.GetString("chaincode.mode")

	return mode == DevModeUserRunsChaincode //“dev”
}

解析:chaincode有两个模式:dev,net,开发模式下无法实例化非系统cc,非开发模式下无法实例化系统cc。ps:系统CC也不让安装啊。

你可能感兴趣的:(fabric)