Warm tip: This article is reproduced from serverfault.com, please click

hyperledger fabric-我们为什么不将锚点对等体第一次放置在通道配置中?

(hyperledger fabric - Why don't we put anchor peers inside channel config for first time generate?)

发布于 2020-12-10 08:29:46

当我们开始使用HF时,我们都知道Hyperledger Fabric示例,对于开始学习时的开始我有一个疑问。要部署测试网络然后创建一个测试通道,我们需要遵循以下步骤(我从createChannel.sh脚本中获取了它们)

## Create channeltx
infoln "Generating channel create transaction '${CHANNEL_NAME}.tx'"
createChannelTx

## Create anchorpeertx
infoln "Generating anchor peer update transactions"
createAncorPeerTx

FABRIC_CFG_PATH=$PWD/../config/

## Create channel
infoln "Creating channel ${CHANNEL_NAME}"
createChannel

## Join all the peers to the channel
infoln "Join Org1 peers to the channel..."
joinChannel 1
infoln "Join Org2 peers to the channel..."
joinChannel 2

## Set the anchor peers for each org in the channel
infoln "Updating anchor peers for org1..."
updateAnchorPeers 1
infoln "Updating anchor peers for org2..."
updateAnchorPeers 2

successln "Channel successfully joined"

我感到很担心,我们需要先执行createChannelTxcreateAncorPeerTx,然后执行createChannelupdateAnchorPeers,让我们查找configtxgen工具的代码

updated := proto.Clone(original).(*cb.ConfigGroup) 

originalOrg, ok := original.Groups[channelconfig.ApplicationGroupKey].Groups[asOrg]
if !ok {
    return errors.Errorf("org with name '%s' does not exist in config", asOrg)
}

if _, ok = originalOrg.Values[channelconfig.AnchorPeersKey]; !ok {
    return errors.Errorf("org '%s' does not have any anchor peers defined", asOrg)
}

delete(originalOrg.Values, channelconfig.AnchorPeersKey)

updt, err := update.Compute(&cb.Config{ChannelGroup: original}, &cb.Config{ChannelGroup: updated})

他们做了什么?只需从原始配置中删除AnchorPeer,然后在创建更新之前和之后进行计算,并返回我的问题。我们是否有一些特殊的问题,无法通过渠道生成锚点对等体并将其全部发送给订单一次?

附加信息:我正在使用结构2.2 LTS

Questioner
Tea
Viewed
11
myeongkil kim 2020-12-10 17:45:11

fabric-2.2 / configtxgen 在文档中

-outputAnchorPeersUpdate 已弃用

fabric-2.x〜将删除outputANchorPeersUpdate ref:FAB-17427

将来,将修改以下代码以在configtxgen进程中反映出来。

if_, ok = originalOrg.Values[channelconfig.AnchorPeersKey]; !ok {
      return errors.Errorf("org'%s' does not have any anchor peers defined", asOrg)
}

delete(originalOrg.Values, channelconfig.AnchorPeersKey)
   -outputAnchorPeersUpdate string
         [DEPRECATED] Creates a config update to update an anchor peer (works only with the default channel creation, and only for the first update)

该选项为DEPRECATED。可能从2.x版本开始,它将被实现为通过configtx.yaml文件添加到创世块中,而无需执行通道更新。