无法在Ubuntu终端上从我的GitHub上运行Hyperledger链码。

huangapple go评论81阅读模式
英文:

cannot run hyperledger chaincode from my own github on Ubuntu terminal

问题

我可以从以下官方路径运行链码:
https://github.com/ibm-blockchain/learn-chaincode/finished
github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

# peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

但是无法从自己的github路径运行链码:
https://github.com/jeffyxia/hyperledger/trade

# peer chaincode deploy -p https://github.com/jeffyxia/hyperledger/trade -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

错误信息如下:

Error: Error building chaincode: rpc error: code = 2 desc = Error getting

chaincode package bytes: Error getting code 'go get' failed with error: "exit status 2"
# github.com/jeffyxia/hyperledger/hello_world
/go/_usercode_/519629987/src/github.com/jeffyxia/hyperledger/hello_world/chaincode_example01.go:31: cannot use new(SimpleChaincode) (type *SimpleChaincode) as type shim.Chaincode in argument to shim.Start:
	*SimpleChaincode does not implement shim.Chaincode (wrong type for Init method)
		have Init(*shim.ChaincodeStub, string, []string) ([]byte, error)
		want Init(shim.ChaincodeStubInterface, string, []string) ([]byte, error)

补充信息:
Ubuntu 16.04 没有安装go语言环境,使用PBFT算法。

如何解决这个问题,谢谢。

英文:

I can run the chaincode from the following official path:
https://github.com/ibm-blockchain/learn-chaincode/finished
github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

# peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

but cannot run chainncode from my own github path:
https://github.com/jeffyxia/hyperledger/trade

# peer chaincode deploy -p https://github.com/jeffyxia/hyperledger/trade -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'

the error info is:

Error: Error building chaincode: rpc error: code = 2 desc = Error getting

chaincode package bytes: Error getting code 'go get' failed with error: "exit status 2"
# github.com/jeffyxia/hyperledger/hello_world
/go/_usercode_/519629987/src/github.com/jeffyxia/hyperledger/hello_world/chaincode_example01.go:31: cannot use new(SimpleChaincode) (type *SimpleChaincode) as type shim.Chaincode in argument to shim.Start:
	*SimpleChaincode does not implement shim.Chaincode (wrong type for Init method)
		have Init(*shim.ChaincodeStub, string, []string) ([]byte, error)
		want Init(shim.ChaincodeStubInterface, string, []string) ([]byte, error)

supplement info:
Ubuntu 16.04 without go language environment, use PBFT algrithm.

how to fix this problem, thx.

答案1

得分: 1

首先,您可能希望从官方存储库中使用最新版本的Fabric。
其次,错误是不言自明的,

  *SimpleChaincode未实现shim.Chaincode(Init方法类型错误)
        具有Init(*shim.ChaincodeStub,string,[]string)([]byte,error)
        要求Init(shim.ChaincodeStubInterface,string,[]string)([]byte,error)

您需要在您的go文件中的所有位置将stub *shim.ChaincodeStub替换为stub shim.ChaincodeStubInterface。请阅读这个链接,https://github.com/IBM-Blockchain/ibm-blockchain-issues/issues/29

英文:

First of all, you may want to use the latest version of fabric from its official repository.
Secondly, the error is self-explanatory,

  *SimpleChaincode does not implement shim.Chaincode (wrong type for Init method)
        have Init(*shim.ChaincodeStub, string, []string) ([]byte, error)
        want Init(shim.ChaincodeStubInterface, string, []string) ([]byte, error)

You need to replace stub *shim.ChaincodeStub with stub shim.ChaincodeStubInterface everywhere in your go file. Please read this as well, https://github.com/IBM-Blockchain/ibm-blockchain-issues/issues/29

huangapple
  • 本文由 发表于 2016年11月9日 11:50:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/40499958.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定