我已经用Java编写了chaincode,并按照文档和教程中的建议创建了一个带有gradle的版本。 解压缩构建tar 文件,当我执行./sample/bin/sample 时,出现以下错误:
./sample/bin/sample -i carchain
Jun 26, 2018 6:16:44 PM org.hyperledger.fabric.shim.ChaincodeBase
newPeerClientConnection
INFO: Configuring channel connection to peer.
Jun 26, 2018 6:16:44 PM org.hyperledger.fabric.shim.impl.ChatStream
<init>
INFO: Connecting to peer.
Jun 26, 2018 6:16:45 PM org.hyperledger.fabric.shim.ChaincodeBas chatWithPeer
INFO: Registering as 'carchain' ... sending REGISTER
Jun 26, 2018 6:16:46 PM org.hyperledger.fabric.shim.impl.ChatStream onError
SEVERE: Unable to connect to peer server: UNKNOWN: Error handling message, ending stream: transition canceled with error: peer will not accepting external chaincode connection name:"carchain" (except in dev mode)
作为参考,我使用了./startFabric.sh --dev 来运行开发网络。
docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
93a888f8900a hyperledger/fabric-peer:x86_64-1.0.4 "peer node start --p…" 17 minutes ago Up 16 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
067df4ba1e86 hyperledger/fabric-couchdb:x86_64-1.0.4 "tini -- /docker-ent…" 17 minutes ago Up 17 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
f7e0f384085b hyperledger/fabric-ca:x86_64-1.0.4 "sh -c 'fabric-ca-se…" 17 minutes ago Up 17 minutes 0.0.0.0:7054->7054/tcp ca.org1.example.com
ad28318f02b2 hyperledger/fabric-orderer:x86_64-1.0.4 "orderer" 17 minutes ago Up 17 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
我什至尝试使用REST API将部署的代码手动部署到 http://127.0.0.1:7051/chaincode {
"jsonrpc": "2.0",
"method": "deploy",
"params": {
"type": 4,
"chaincodeID": {
"path": "/home/nitish/IdeaProjects/sample/out/production/classes/com/sample",
"name": "car-chaincode"
},
"ctorMsg": {
"function": "init",
"args": [
"3",
"100",
"b",
"200",
"4"
]
},
"secureContext": "jim"
},
"id": 1
}
但是,出现错误:无法联系服务器
我想念什么吗?我应该如何部署它?