Skip to content

Commit

Permalink
[FAB-1944] Part 1: Remove utils.EncodeAnchorPeers
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Jan 30, 2017
1 parent 0122a04 commit 3b7a9ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
11 changes: 6 additions & 5 deletions common/configtx/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -34,7 +35,7 @@ const (
AcceptAllPolicyKey = "AcceptAllPolicy"
)

var template configtx.Template
var ordererTemplate configtx.Template

var genesisFactory genesis.Factory

Expand Down Expand Up @@ -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) {
Expand All @@ -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
}
3 changes: 2 additions & 1 deletion peer/channel/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 0 additions & 11 deletions protos/utils/blockutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 3b7a9ec

Please sign in to comment.