Hyperledger-fabric无法实例化链码

时间:2018-04-17 14:08:07

标签: go hyperledger-fabric hyperledger

我无法在Hyperledge Fabric中实例化链码。

执行时:

peer chaincode instantiate -o orderer -n test_cc -C test-channel -v 0.1 -c '{"Args":["initLedger"]}'

我收到错误:

peer0       | 2018-04-17 13:02:11.097 UTC [dockercontroller] Start -> ERRO 046 start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}

在互联网上搜索时,错误消息与[OCI Runtimer Error when installing Hyperledger Chaincode via Java-SDK和[OCI runtime error when sending Hyperledger Fabric's chaincode instantiation request to peers上的原始帖子相同,但这些帖子的评论并未导致我找到解决方案。

我使用以下软件版本: Hyperledger 1.1.0 Docker版本18.03.0-ce(在Linux上),Hyperledger Docker镜像:x86_64-1.1.0

以下步骤成功:

  • 构建链码。代码编译没有错误。我没有包含任何依赖项,除了两个必需的" github.com/hyperledger/fabric/core/chaincode/shim"和 " github.com/hyperledger/fabric/protos/peer"
  • 打包链码。
  • 签署链码。
  • 安装链码(它最终在同行的/var/hyperledger/production/chaincodes/test_cc.0.1。

(根据Hyperledger文档的步骤:[http://hyperledger-fabric-docs.readthedocs.io/en/latest/chaincode4noah.html]

在CLI Docker容器中,文件位于/opt/gopath/src/chaincode/go/test_cc/目录中,其中存在4个文件:test_cc, test_cc.go, test_cc_pack.out, test_cc_signed_pack.out(二进制文件,源文件,打包文件和签名包文件)。

订货人和同行的完整输出是:

orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/server] Broadcast -> DEBU 167 Starting new Broadcast handler
orderer    | 2018-04-17 13:29:43.617 UTC [orderer/common/broadcast] Handle -> DEBU 168 Starting new broadcast loop for 172.18.0.6:41228
couchdb    | [notice] 2018-04-17T13:29:43.624931Z nonode@nohost <0.16042.3> b5d38cd27d couchdb:5984 172.18.0.5 undefined GET /test-channel_lscc/test_cc?attachments=true 404 ok 2
peer       | 2018-04-17 13:29:44.416 UTC [dockercontroller] Start -> ERRO 04a start-could not start container: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 2018-04-17 13:29:44.647 UTC [chaincode] Launch -> ERRO 04b launchAndWaitForRegister failed: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
peer       | 2018-04-17 13:29:44.647 UTC [endorser] simulateProposal -> ERRO 04c [test-channel][39e4414a] failed to invoke chaincode name:"lscc" , error: API error (400): {"message":"OCI runtime create failed: container_linux.go:348: starting container process caused \"exec: \\\"chaincode\\\": executable file not found in $PATH\": unknown"}
peer       | 
peer       | error starting container
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/broadcast] Handle -> DEBU 169 Received EOF from 172.18.0.6:41228, hangup
orderer    | 2018-04-17 13:29:44.648 UTC [orderer/common/server] func1 -> DEBU 16a Closing Broadcast stream

看起来有一些路径问题,但是链码容器的创建过程和影响这个过程的变量。

我现在已经解决了这个问题几天(!),尝试了所有路径组合,例如将文件放在/opt/gopath/bin等等,但无济于事。

能否在这个问题上发光的人?或者知道正确的路径是什么,它们在哪里,或者应该在哪里定义?

由于

1 个答案:

答案 0 :(得分:3)

问题在于我在Go源文件中使用了包test_package&#39;,在构建时,它不会创建可执行文件,而是创建可链接的目标文件。

包装主要&#39;在我的Go文件中,然后重建和重新打包,使对等链码安装&#39;和&#39;对等链代码实例化&#39;命令按预期工作。