diff --git a/common/configtx/test/helper.go b/common/configtx/test/helper.go index c3e28099cfc..8a08252950c 100644 --- a/common/configtx/test/helper.go +++ b/common/configtx/test/helper.go @@ -22,6 +22,7 @@ import ( "github.com/hyperledger/fabric/common/configtx" "github.com/hyperledger/fabric/common/genesis" + peersharedconfig "github.com/hyperledger/fabric/peer/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" @@ -34,7 +35,7 @@ const ( AcceptAllPolicyKey = "AcceptAllPolicy" ) -var template configtx.Template +var ordererTemplate configtx.Template var genesisFactory genesis.Factory @@ -62,10 +63,10 @@ func init() { panic(err) } - template = configtx.NewSimpleTemplate(templateProto.Items...) + ordererTemplate = configtx.NewSimpleTemplate(templateProto.Items...) anchorPeers := []*peer.AnchorPeer{{Host: "fakehost", Port: 2000, Cert: []byte{}}} - gossTemplate := configtx.NewSimpleTemplate(utils.EncodeAnchorPeers(anchorPeers)) - genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(MSPTemplate{}, template, gossTemplate)) + gossTemplate := configtx.NewSimpleTemplate(peersharedconfig.TemplateAnchorPeers(anchorPeers)) + genesisFactory = genesis.NewFactoryImpl(configtx.NewCompositeTemplate(MSPTemplate{}, ordererTemplate, gossTemplate)) } func MakeGenesisBlock(chainID string) (*cb.Block, error) { @@ -74,5 +75,5 @@ func MakeGenesisBlock(chainID string) (*cb.Block, error) { // GetOrderererTemplate returns the test orderer template func GetOrdererTemplate() configtx.Template { - return template + return ordererTemplate } diff --git a/peer/channel/create.go b/peer/channel/create.go index 2fb684f69ac..075911cea2f 100644 --- a/peer/channel/create.go +++ b/peer/channel/create.go @@ -26,6 +26,7 @@ import ( mspmgmt "github.com/hyperledger/fabric/msp/mgmt" "github.com/hyperledger/fabric/orderer/common/bootstrap/provisional" "github.com/hyperledger/fabric/peer/common" + "github.com/hyperledger/fabric/peer/sharedconfig" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" "github.com/spf13/cobra" @@ -55,7 +56,7 @@ func sendCreateChainTransaction(cf *ChannelCmdFactory) error { //TODO this is a temporary hack until `orderer.template` is supplied from the CLI oTemplate := configtxtest.GetOrdererTemplate() mspTemplate := configtx.NewSimpleTemplate(utils.EncodeMSPUnsigned(chainID)) - gossTemplate := configtx.NewSimpleTemplate(utils.EncodeAnchorPeers(anchorPeers)) + gossTemplate := configtx.NewSimpleTemplate(sharedconfig.TemplateAnchorPeers(anchorPeers)) chCrtTemp := configtx.NewCompositeTemplate(oTemplate, mspTemplate, gossTemplate) signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity() diff --git a/protos/utils/blockutils.go b/protos/utils/blockutils.go index 6e1344198c7..7cb8149f649 100644 --- a/protos/utils/blockutils.go +++ b/protos/utils/blockutils.go @@ -25,7 +25,6 @@ import ( "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" - "github.com/hyperledger/fabric/protos/peer" ) // GetChainIDFromBlock returns chain ID in the block @@ -194,13 +193,3 @@ func EncodeMSP(chainID string) *cb.SignedConfigurationItem { MarshalOrPanic(conf), xxxDefaultModificationPolicyID, cb.ConfigurationItem_MSP) } - -// EncodeAnchorPeers returns a configuration item with anchor peers -func EncodeAnchorPeers(anchorPeers []*peer.AnchorPeer) *cb.ConfigurationItem { - apConfig := &peer.AnchorPeers{ - AnchorPeers: anchorPeers, - } - rawAnchorPeers := MarshalOrPanic(apConfig) - // We don't populate the chainID because that value is over-written later on anyway - return createConfigItem("", AnchorPeerConfItemKey, rawAnchorPeers, xxxDefaultModificationPolicyID, cb.ConfigurationItem_Peer) -}