2017-09-28 27 views
1

我一直在关注Hyperledger的基本网络教程,我正在探索有2个对等点和2个频道的可能性,每个频道有一个对等点。如何在Hyperledger中为新频道创建新对等点

../bin/configtxgen -profile OneOrgChannel -outputCreateChannelTx /config/channel2.tx -channelID mychannel2 

但是,我不知道如何创建第二对添加到这个频道:

我已经创建了第二信道配置文件使用configtxgen的命令调用mychannel2.tx。我的猜测是我必须配置crypto-config.yaml文件,但我不知道如何添加对等点

但是,一旦我添加了一个同行,我应该能够使用basic network tutorial的start.sh脚本来创建一个频道,但第二对加入该频道就像这样:

# Create the channel 
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx 

# Join peer0.org1.example.com to the channel. 
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b mychannel.block 

回答

1

创建新的同伴您只需为其组织签署的同伴生成适当的加密材料。为了这个目的,你可以使用cryptogen CLI工具,在那里你根本就重用现有crypto-config.yaml文件,你需要使用模板定义组织同行的号,有多少用户证书生成:

PeerOrgs: 
    - Name: Org1 
    Domain: org1.example.com 
    Template: 
     Count: 2 
    Users: 
     Count: 1 
    - Name: Org2 
    Domain: org2.example.com 
    Template: 
     Count: 2 
    Users: 
     Count: 1 

在例如上面每个组织定义两个对等组织和一个用户组织。

接下来,您必须定义与configtxgen通道指定你的要求,你如果你想有:

2 peers and 2 channels, one peer for each channel.

因此需要定义配置文件将指定这些渠道,现在的问题,只要这些同行是否属于同一组织。来自不同组织的假设他们,因此配置将类似于以下内容:

Profiles: 

    TwoOrgsOrdererGenesis: 
     Orderer: 
      <<: *OrdererDefaults 
      Organizations: 
       - *OrdererOrg 
     Consortiums: 
      SampleConsortium: 
       Organizations: 
        - *Org1 
        - *Org2 
    ChannelOne: 
     Consortium: SampleConsortium 
     Application: 
      <<: *ApplicationDefaults 
      Organizations: 
       - *Org1 
    ChannelTwo: 
     Consortium: SampleConsortium 
     Application: 
      <<: *ApplicationDefaults 
      Organizations: 
       - *Org2 

现在,你需要生成配置交易两个通道产生成因块,并能够加盟渠道。

FABRIC_CFG_PATH=. configtxgen -profile ChannelOne -channelID channelone -outputCreateChannelTx=channelone.tx 

FABRIC_CFG_PATH=. configtxgen -profile ChannelTwo -channelID channeltwo -outputCreateChannelTx=channeltwo.tx 

最后,一旦你为每个通道配置的交易可以将其提交给订购服务创建一个新的渠道,后来加入到同行合适的渠道。请注意,您并不需要更改crypto-config.yaml

+0

第二个问题是,如果我确实玩过'configtx.yaml',除了你在这里展示的东西,我还必须编辑“组织”部分的权利? (在其中添加组织信息) – OneMoreQuestion

+0

第一个问题:为什么我不需要更改'crypto-config.yaml'?我以为我需要使用它来生成对等工件? – OneMoreQuestion

+0

'cryptogen'工具例如'crypto-config.yaml'用于为同伴,管理员和用户生成加密资料。在你的情况下,你可以直接使用它,因为每个组织只需要两个对等体。 –