Skip to content

Commit 3b7a9ec

Browse files
author
Jason Yellick
committed
[FAB-1944] Part 1: Remove utils.EncodeAnchorPeers
https://jira.hyperledger.org/browse/FAB-1944 This is redundant code which is specified in a more consistent way via peer/sharedconfig/sharedconfig_util.go Change-Id: Ifc3dcd9cf3f0f7719abd4c54fd662106e4fbb1b5 Signed-off-by: Jason Yellick <[email protected]>
1 parent 0122a04 commit 3b7a9ec

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

common/configtx/test/helper.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/hyperledger/fabric/common/configtx"
2424
"github.com/hyperledger/fabric/common/genesis"
25+
peersharedconfig "github.com/hyperledger/fabric/peer/sharedconfig"
2526
cb "github.com/hyperledger/fabric/protos/common"
2627
"github.com/hyperledger/fabric/protos/utils"
2728

@@ -34,7 +35,7 @@ const (
3435
AcceptAllPolicyKey = "AcceptAllPolicy"
3536
)
3637

37-
var template configtx.Template
38+
var ordererTemplate configtx.Template
3839

3940
var genesisFactory genesis.Factory
4041

@@ -62,10 +63,10 @@ func init() {
6263
panic(err)
6364
}
6465

65-
template = configtx.NewSimpleTemplate(templateProto.Items...)
66+
ordererTemplate = configtx.NewSimpleTemplate(templateProto.Items...)
6667
anchorPeers := []*peer.AnchorPeer{{Host: "fakehost", Port: 2000, Cert: []byte{}}}
67-
gossTemplate := configtx.NewSimpleTemplate(utils.EncodeAnchorPeers(anchorPeers))
68-
genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(MSPTemplate{}, template, gossTemplate))
68+
gossTemplate := configtx.NewSimpleTemplate(peersharedconfig.TemplateAnchorPeers(anchorPeers))
69+
genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(MSPTemplate{}, ordererTemplate, gossTemplate))
6970
}
7071

7172
func MakeGenesisBlock(chainID string) (*cb.Block, error) {
@@ -74,5 +75,5 @@ func MakeGenesisBlock(chainID string) (*cb.Block, error) {
7475

7576
// GetOrderererTemplate returns the test orderer template
7677
func GetOrdererTemplate() configtx.Template {
77-
return template
78+
return ordererTemplate
7879
}

peer/channel/create.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
mspmgmt "github.com/hyperledger/fabric/msp/mgmt"
2727
"github.com/hyperledger/fabric/orderer/common/bootstrap/provisional"
2828
"github.com/hyperledger/fabric/peer/common"
29+
"github.com/hyperledger/fabric/peer/sharedconfig"
2930
cb "github.com/hyperledger/fabric/protos/common"
3031
"github.com/hyperledger/fabric/protos/utils"
3132
"github.com/spf13/cobra"
@@ -55,7 +56,7 @@ func sendCreateChainTransaction(cf *ChannelCmdFactory) error {
5556
//TODO this is a temporary hack until `orderer.template` is supplied from the CLI
5657
oTemplate := configtxtest.GetOrdererTemplate()
5758
mspTemplate := configtx.NewSimpleTemplate(utils.EncodeMSPUnsigned(chainID))
58-
gossTemplate := configtx.NewSimpleTemplate(utils.EncodeAnchorPeers(anchorPeers))
59+
gossTemplate := configtx.NewSimpleTemplate(sharedconfig.TemplateAnchorPeers(anchorPeers))
5960
chCrtTemp := configtx.NewCompositeTemplate(oTemplate, mspTemplate, gossTemplate)
6061

6162
signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity()

protos/utils/blockutils.go

-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/hyperledger/fabric/msp"
2727
cb "github.com/hyperledger/fabric/protos/common"
28-
"github.com/hyperledger/fabric/protos/peer"
2928
)
3029

3130
// GetChainIDFromBlock returns chain ID in the block
@@ -194,13 +193,3 @@ func EncodeMSP(chainID string) *cb.SignedConfigurationItem {
194193
MarshalOrPanic(conf),
195194
xxxDefaultModificationPolicyID, cb.ConfigurationItem_MSP)
196195
}
197-
198-
// EncodeAnchorPeers returns a configuration item with anchor peers
199-
func EncodeAnchorPeers(anchorPeers []*peer.AnchorPeer) *cb.ConfigurationItem {
200-
apConfig := &peer.AnchorPeers{
201-
AnchorPeers: anchorPeers,
202-
}
203-
rawAnchorPeers := MarshalOrPanic(apConfig)
204-
// We don't populate the chainID because that value is over-written later on anyway
205-
return createConfigItem("", AnchorPeerConfItemKey, rawAnchorPeers, xxxDefaultModificationPolicyID, cb.ConfigurationItem_Peer)
206-
}

0 commit comments

Comments
 (0)