在远程同行

时间:2017-04-09 00:43:10

标签: hyperledger hyperledger-fabric

我正在尝试在2个实例上使用Hyperledger fabric v1.0设置简单的区块链网络。

我的方案

实例A:Orderer和Peer0
实例B:Peer1

我基本上遵循了“Getting Started”页面的“使用原生二进制文件”部分。

我尝试的是我在instanceA上启动了1个orderer和1个peer。 我安装,实例化,调用并查询了示例链代码。

然后我在instanceB上启动了1个peer。 我可以让instanceB上的peer1从instanceA加入我的频道。我可以在instanceA上的peer1上安装链码。

但我无法从instanceA执行查询peer1。 我至少可以看到在instanceB上安装的链代码。

错误信息是:

Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1


以下是我试过的命令..

[InstanceA terminal1] 1.生成orderer.block
$ configtxgen -profile SampleSingleMSPSolo -outputBlock orderer.block

[InstanceA terminal2] 2.启动订货人
$ CORE_PEER_LOCALMSPID = DEFAULT CORE_LOGGING_LEVEL = DEBUG ORDERER_GENERAL_LISTENADDRESS = 0.0.0.0 ORDERER_GENERAL_GENESISMETHOD = file ORDERER_GENERAL_GENESISFILE =。/ orderer.block

2017-04-08 23:38:41.562 UTC [orderer/multichain] NewManagerImpl -> INFO 001 Starting with system channel testchainid and orderer type solo
2017-04-08 23:38:41.562 UTC [orderer/main] NewServer -> INFO 002 Starting orderer
2017-04-08 23:38:41.562 UTC [orderer/main] main -> INFO 003 Beginning to serve requests
2017-04-08 23:39:39.881 UTC [orderer/multichain] newChain -> INFO 004 Created and starting new chain mychannel1


[InstanceA terminal1] 3.生成channel.tx
$ configtxgen -profile SampleSingleMSPSolo -outputCreateChannelTx channel.tx -channelID mychannel1

[InstanceA terminal3] 4.启动peer0
$ CORE_PEER_GOSSIP_EXTERNALENDPOINT = 127.0.0.1:7051 CORE_LOGGING_LEVEL = DEBUG CORE_PEER_LOCALMSPID = DEFAULT对等节点启动--peer-defaultchain = false

[InstanceA terminal1] 5.创建频道
$ CORE_PEER_LOCALMSPID = DEFAULT对等通道创建-o 127.0.0.1:7050 -c mychannel1 -f channel.tx

[InstanceA terminal1] 6.将peer0加入mychannel1
$ CORE_PEER_LOCALMSPID = DEFAULT对等通道加入-b mychannel1.block

Peer joined the channel!
2017-04-08 23:39:54.463 UTC [main] main -> INFO 001 Exiting.....

[InstanceA terminal1] 7.安装链码
$ CORE_PEER_LOCALMSPID = DEFAULT peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

ncode/go/chaincode_example02
2017-04-08 23:40:05.744 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:05.744 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:40:36.242 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 7.实例化链码
$ CORE_PEER_ADDRESS = 127.0.0.1:7051 CORE_PEER_LOCALMSPID = DEFAULT peer chaincode instantiate -o 127.0.0.1:7050 -C mychannel1 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c' {“Args”:[“init”,“a”,“100”,“b”,“200”]}'

 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a", "100", "b","200"]}'
2017-04-08 23:40:39.892 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2017-04-08 23:40:39.893 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2017-04-08 23:40:42.194 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 8.调用并查询命令
$ CORE_PEER_ADDRESS = 127.0.0.1:7051 peer chaincode invoke -o 127.0.0.1:7050 -C mychannel1 -n mycc -c'{“Args”:[“invoke”,“a”,“b”,“10”]} “ $ CORE_PEER_ADDRESS = 127.0.0.1:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c'{“Args”:[“query”,“a”]}'

Query Result: 90
2017-04-08 23:40:51.664 UTC [main] main -> INFO 001 Exiting.....

[InstanceB terminal1] 9.在instanceB上创建peer1 $ CORE_PEER_MSPCONFIGPATH = / home / kouohhashi / work / src / github.com / hyperledger / fabric / msp / sampleconfig CORE_PEER_GOSSIP_EXTERNALENDPOINT = instanceB:7051 CORE_LOGGING_LEVEL = DEBUG CORE_PEER_LOCALMSPID = DEFAULT对等节点启动--peer-defaultchain = false

[InstanceA terminal1] 10.将实例B上的peer1加入来自instanceA的mychannel1 $ CORE_PEER_LOCALMSPID = DEFAULT CORE_PEER_ADDRESS = instanceB:7051 peer channel join -b mychannel1.block

Peer joined the channel!
2017-04-08 23:42:14.799 UTC [main] main -> INFO 001 Exiting.....

[InstanceA terminal1] 11.在实例A的peer1上安装实例A的链代码 $ CORE_PEER_LOCALMSPID = DEFAULT CORE_PEER_ADDRESS = instanceB:7051 peer chaincode install -o 127.0.0.1:7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02

2017-04-08 23:42:23.166 UTC [golang-platform] writeGopathSrc -> INFO 001 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:23.166 UTC [container] WriteFolderToTarPackage -> INFO 002 rootDirectory = /home/kouohhashi/work/src
2017-04-08 23:42:39.191 UTC [main] main -> INFO 003 Exiting.....

[InstanceA terminal1] 12.从instanceA查询peer1 $ CORE_PEER_ADDRESS = instanceB:7051 peer chaincode query -o 127.0.0.1:7050 -C mychannel1 -n mycc -c'{“Args”:[“query”,“a”]}'

  

我收到如下错误。但我至少可以看到mycc链码   instnceB和peer join命令已成功完成。


Error: Error endorsing query: rpc error: code = 2 desc = failed to obtain cds for mycc - transaction not found mycc/mychannel1


我正在使用2个ubuntu16.04实例,而根本没有使用docker或vagrant。我通过make native编译了二进制文件。

instanceB上的Peer1可能无法在instanceA上连接orderer,因为我在peer1上看到了错误日志。

2017-04-08 23:42:14.903 UTC [deliveryClient] NewDeliverService -> ERRO 286 Cannot dial to 0.0.0.0:7050, because of grpc: timed out when dialing

看起来peer1尝试连接0.0.0.0而不是instanceA。

顺便说一下,我从SampleOrg将组织名称更改为DEFAULT,因为我收到的错误如下所示。

2017-04-08 05:17:57.919 UTC [gossip/service] configUpdated -> ERRO 25e Tried joining channel mychannel1 but our org( DEFAULT ), isn't among the orgs of the channel: [SampleOrg] , aborting.

我认为这可能是因为instanceB上的peer1没有链接到instanceA上的orderder,或者peer0创建的事务没有完成并反映在instanceB上。但我不知道如何挖掘...

请给我帮助。
感谢。

1 个答案:

答案 0 :(得分:0)

我终于解决了我的问题。 事实证明我很简单。

解决方案是将订货人的地址从127.0.0.1:7050更改为(InstanceA的IP地址):7050

common / configtx / tool / configtx.yaml

Orderer: &OrdererDefaults

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

    Addresses:
        # - 127.0.0.1:7050
        - <IP Address of InstanceA>:7050

通过这样做,instanceB上的Peer1开始连接instanceA上的orderer。

它看起来像&#34; CORE_PEER_COMMITTER_LEDGER_ORDERER环境参数&#34;和&#34; -o选项&#34;不再使用或被configtx.yaml覆盖。