无法在Ubuntu终端

时间:2016-11-09 03:50:06

标签: go ubuntu-16.04 hyperledger hyperledger-fabric

我可以从以下官方路径运行链码: 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错误:代码= 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)

补充资料: Ubuntu 16.04没有go语言环境,使用PBFT algrithm。

如何解决这个问题,thx。

1 个答案:

答案 0 :(得分:1)

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

  *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