当我们开始使用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"
我感到很担心,我们需要先执行createChannelTx和createAncorPeerTx,然后执行createChannel和updateAnchorPeers,让我们查找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
-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文件添加到创世块中,而无需执行通道更新。
感谢您的答复,但“但是,配置锚点对等点还不够。” 在配置中遗漏了哪一点。
其次,您的事件可以在对等方加入频道之前更新锚点对等体
第三,我想他们似乎把所有内容都放在configtx.yaml上以节省时间或其他我不知道的东西;
首先,“仅配置锚点对等点还不够。” 实际上,很抱歉,但我没有对此进行深入研究,请参阅上面的链接以获取详细信息。
1,您提到的链接是另一个问题。我猜。当我调试代码时,Anchor仅查看主机和端口,仅此而已。