为什么我们不在第一次生成时将锚点放在通道配置中?
Why don't we put anchor peers inside channel config for first time generate?
我们都知道Hyperledger Fabric Sample开始使用HF的时候,我开始学习的时候有一个问题。要部署 test-network 然后创建测试通道,我们需要按照下面的一些步骤进行操作 (我从 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 并在创建更新之前和之后进行计算,然后回答我的问题。 我们有什么特殊的问题不生成带通道的anchor peer并把它们全部发送一次吗?
其他信息:我使用的是 fabric 2.2 LTS
-outputAnchorPeersUpdate
已弃用
fabric-2.x ~ 将删除 outputANchorPeersUpdate
参考: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)
该选项已弃用。
大概从2.x版本开始,会实现通过configtx.yaml文件添加到创世块而不进行通道更新。
我们都知道Hyperledger Fabric Sample开始使用HF的时候,我开始学习的时候有一个问题。要部署 test-network 然后创建测试通道,我们需要按照下面的一些步骤进行操作 (我从 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 并在创建更新之前和之后进行计算,然后回答我的问题。 我们有什么特殊的问题不生成带通道的anchor peer并把它们全部发送一次吗?
其他信息:我使用的是 fabric 2.2 LTS
-outputAnchorPeersUpdate
已弃用
fabric-2.x ~ 将删除 outputANchorPeersUpdate 参考: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)
该选项已弃用。 大概从2.x版本开始,会实现通过configtx.yaml文件添加到创世块而不进行通道更新。