我尝试按照步骤here实例化链码。请注意,我正在使用NodeJ(并且在下面省略了我的实际令牌):
curl -s -X POST \
http://localhost:4000/channels/mychannel/chaincodes \
-H "authorization: Bearer <put JSON Web Token here>" \
-H "content-type: application/json" \
-d '{
"chaincodeName":"mycc",
"chaincodeVersion":"v0",
"chaincodeType": "node",
"args":["a","100","b","200"]
}'
但是在运行node app
的窗口中出现此错误:
[2018-11-15 00:46:54.627] [INFO] instantiate-chaincode - instantiate proposal was good
[2018-11-15 00:46:54.628] [ERROR] instantiate-chaincode - instantiate proposal was bad
[2018-11-15 00:46:54.628] [DEBUG] instantiate-chaincode - Failed to send Proposal and receive all good ProposalResponse
[2018-11-15 00:46:54.628] [ERROR] instantiate-chaincode - Failed to instantiate. cause:Failed to send Proposal and receive all good ProposalResponse
(node:73116) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: Failed to instantiate. cause:Failed to send Proposal and receive all good ProposalResponse
我已粘贴完整日志here。谁能帮我解决这个问题?我遵循了link之前的所有步骤,没有遇到麻烦:
我还可以看到一个名称为dev-peer0.org1.example.com-mycc-v0
的容器,它与调试日志一起显示链码是在peer0上实例化的,但是为什么它却没有在peer1上实例化呢?
docker-compose.yaml中这些端口的含义是什么?
peer0.org1.example.com:
container_name: peer0.org1.example.com
ports:
- 7051:7051
- 7053:7053
peer1.org1.example.com:
container_name: peer1.org1.example.com
ports:
- 7056:7051
- 7058:7053
答案 0 :(得分:1)
我今天再次尝试了修改,指定了如下所示的对等体:
curl -s -X POST \
http://localhost:4000/channels/mychannel/chaincodes \
-H "authorization: Bearer <put JSON Web Token here>" \
-H "content-type: application/json" \
-d '{
"peers": ["peer1.org1.example.com"],
"chaincodeName":"mycc",
"chaincodeVersion":"v0",
"chaincodeType": "node",
"args":["a","100","b","200"]
}'
这次成功了:
{"success":true,"message":"Successfully instantiate chaincode in organization Org1 to the channel 'mychannel'"}
在节点应用程序终端中:
[2018-11-15 22:12:26.463] [INFO] instantiate-chaincode - The chaincode instantiate transaction has been committed on peer localhost:7051
[2018-11-15 22:12:26.463] [INFO] instantiate-chaincode - Transaction 979eeb030e6adf9689f39163192fbb9bcba00e6942ef4d1ea6de10d982d234fe has status of VALID in blocl 1
[2018-11-15 22:12:26.464] [INFO] instantiate-chaincode - The chaincode instantiate transaction was valid.
[2018-11-15 22:12:26.464] [DEBUG] instantiate-chaincode - ------->>> R E S P O N S E : ["The chaincode instantiate transaction was valid.",{"status":"SUCCESS","info":""}]
[2018-11-15 22:12:26.465] [INFO] instantiate-chaincode - Successfully sent transaction to the orderer.
[2018-11-15 22:12:26.467] [DEBUG] instantiate-chaincode - Event results for event hub :localhost:7051
[2018-11-15 22:12:26.468] [DEBUG] instantiate-chaincode - The chaincode instantiate transaction was valid.
[2018-11-15 22:12:26.468] [INFO] instantiate-chaincode - Successfully instantiate chaincode in organization Org1 to the channel 'mychannel'
我不知道为什么它昨天失败了,今天又成功了。
今天,当我最初提出curl
请求时,它也失败了,因为JWT令牌已过期。为了刷新令牌,我向/users
端点发出了请求,就像我昨天注册用户一样(这次用户已经被注册了)
curl -s -X POST http://localhost:4000/users -H "content-type: application/x-www-form-urlencoded" -d 'username=Jim&orgName=Org1'
下面显示了容器:
$ docker ps --format '{{.Names}}'
dev-peer1.org1.example.com-mycc-v0
dev-peer0.org1.example.com-mycc-v0
peer1.org2.example.com
peer0.org2.example.com
peer0.org1.example.com
peer1.org1.example.com
ca_peerOrg1
ca_peerOrg2
orderer.example.com
并从实例化链码的容器中记录日志: $ docker logs -f dev-peer1.org1.example.com-mycc-v0
> example_cc@1.0.0 start /usr/local/src
> node example_cc.js "--peer.address" "peer1.org1.example.com:7052"
E1115 22:12:23.956612869 17 ssl_transport_security.cc:238] Could not get common name of subject from certificate.
========= example_cc Init =========
{ fcn: 'node', params: [ 'a', '100', 'b', '200' ] }