2016-11-09 41 views
1

我可以運行從以下官方路徑chaincode: https://github.com/ibm-blockchain/learn-chaincode/finished github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02無法從我自己的Ubuntu終端上運行GitHub的hyperledger chaincode

# 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"]}' 

錯誤信息是:

錯誤:錯誤建築chaincode: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,而不去的語言環境中,使用PBFT algrithm。

如何解決這個問題,thx。

回答

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) 

你需要在你的旅途中文件,stub shim.ChaincodeStubInterface更換stub *shim.ChaincodeStub無處不在。請仔細閱讀,https://github.com/IBM-Blockchain/ibm-blockchain-issues/issues/29