为什么对等链码实例化成功执行多次 [英] Why peer chaincode instantiate execuate many times successfully

查看:81
本文介绍了为什么对等链码实例化成功执行多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以成功执行多次peer chaincode instantiate,它应该返回它的存在,但没有.为什么?

I could execute peer chaincode instantiate many times successfully, it should returns it exist, but no. why?

实例化命令后的日志

记录docker返回的日志

步骤:

来自我的github项目chaincode-docker-devmode ,我复制msp(对等和订购者一起使用),genesis.block,helloch.tx,docker-compose-with-couch.yaml等到其他地方,应该没问题.当我执行时:

from my github project chaincode-docker-devmode, I copy msp (peer and orderer use together) 、genesis.block、helloch.tx、docker-compose-with-couch.yaml and so on form other place,it should be ok. When I execute :

docker-compose -f docker-compose-with-couch.yaml up

peer,orderer,couchdb0,cli start,然后cli执行script.sh

peer、orderer、couchdb0、cli start and then cli execute script.sh

#script.sh content
peer channel create -c helloch -f helloch.tx -o orderer:7050
peer channel join -b helloch.block

然后我通过以下方式在chaincode-docker-devmode当前路径下使用终端模拟cli环境:

then I simulate cli enviroment using terminal at chaincode-docker-devmode current path by following:

#cli simulation, $pwd  is the chaincode-docker-devmode path
export CORE_VM_ENDPOINT=unix:///var/run/run/docker.sock
export CORE_LOGGING_LEVEL=DEBUG
export CORE_PEER_ID=cli
export CORE_PEER_ADDRESS=127.0.0.1:7051
export CORE_PEER_LOCALMSPID=DEFAULT
export CORE_PEER_MSPCONFIGPATH=$pwd/msp
bash

当我执行peer channel list时,可能表明我已经加入 helloch

When I execute peer channel list It could shows I have join helloch

频道.然后我执行:

peer chaincode install -n hello -v 1.0 -l java -p chaincode/hsl-hsl-user-guide-examples-v14/mytest
peer chaincode instantiate -o 127.0.0.1:7050 -C helloch  -n hello -v 1.0 -l java -c "{\"Args\":[\"init\",\"a\", \"100\", \"b\",\"100\"]}"

但是我可以实例化很多次,并且日志不会返回错误

But I can instantiate many times and the log does not return error as same as above instantiate logs, actually it does not instantiate successfully, why?

推荐答案

实例化链码本质上是一项交易,因此必须对其进行认可,订购和承诺生效.现在,在您的情况下,由于交易建议书成功认可并签署了提交给订购服务的建议书,所以对等cli实例化命令成功执行.而基于以下日志输出:

Instantiate of the chaincode is essentially a transaction, therefore it has to be endorsed, ordered and committed to take effect. Now in your case peer cli instantiate command succeeds since the transaction proposal successfully endorsed and signed proposal submitted to the ordering service. While based on the following log output:

peer        | 2017-09-05 01:09:23.650 UTC [ConnProducer] NewConnection -> ERRO 6da Failed connecting to 127.0.0.1:7050 , error: context deadline exceeded
peer        | 2017-09-05 01:09:23.650 UTC [deliveryClient] connect -> ERRO 6db Failed obtaining connection: Could not connect to any of the endpoints: [127.0.0.1:7050]

对等无法连接到订购服务端点,在您的情况下,该端点被配置为127.0.0.1:7050,因此最终不会实例化事务.因此,您可以再次执行实例化命令,因为以前的尝试在对等分类账上不存在实例化交易记录.

Peer cannot get connected to the ordering service endpoint which in your case configured to be 127.0.0.1:7050, therefore eventually instantiate transaction is not committed. Therefore you do able to execute the instantiate command again, since no instantiate transaction record exists on the peer ledger from your previous attempt.

您需要将订购服务端点从127.0.0.1:7050更改为orderer:7050,然后重试实验.在configtx.yaml文件中配置的该值,例如:

You need to change ordering service endpoint from 127.0.0.1:7050 to orderer:7050 and retry your experiment. This value configured inside configtx.yaml file, e.g.:

Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    # Available types are "solo" and "kafka"
    OrdererType: solo

    Addresses:
        - orderer:7050

这篇关于为什么对等链码实例化成功执行多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆