无法在 Ubuntu 终端上从我自己的 github 运行 hyperledger 链码

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 路径 运行 chainncode: https://github.com/jeffyxia/hyperledger/trade

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

错误信息是:

错误:构建链代码时出错:rpc 错误:code = 2 desc = 获取

时出错
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)

补充信息: Ubuntu16.04没有go语言环境,使用PBFT算法

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

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

  *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)

您需要将 go 文件中的所有地方的 stub *shim.ChaincodeStub 替换为 stub shim.ChaincodeStubInterface。请也阅读此内容,https://github.com/IBM-Blockchain/ibm-blockchain-issues/issues/29