首页 文章

Hyperledger-fabric无法实例化链码

提问于
浏览
0

我无法在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 回答

  • 3

    问题是在Go源文件中我使用了'package test_package',它在构建时不会创建可执行文件,而是创建可链接的目标文件 .

    在我的Go文件中使用'package main',然后重建和重新打包,使'peer chaincode install'和'peer chaincode instantiate'命令按预期工作 .

相关问题