diff --git a/common/configtx/handlers/application/sharedconfig.go b/common/configtx/handlers/application/sharedconfig.go index 2fa480cb1d2..c9004afc473 100644 --- a/common/configtx/handlers/application/sharedconfig.go +++ b/common/configtx/handlers/application/sharedconfig.go @@ -57,7 +57,7 @@ var Schema = &cb.ConfigGroupSchema{ // Peer config keys const ( - // AnchorPeersKey is the cb.ConfigItem type key name for the AnchorPeers message + // AnchorPeersKey is the key name for the AnchorPeers ConfigValue AnchorPeersKey = "AnchorPeers" ) diff --git a/common/configtx/handlers/application/sharedconfig_test.go b/common/configtx/handlers/application/sharedconfig_test.go index 6ce20217b4f..3ba2b2a2724 100644 --- a/common/configtx/handlers/application/sharedconfig_test.go +++ b/common/configtx/handlers/application/sharedconfig_test.go @@ -37,8 +37,11 @@ func makeInvalidConfigValue() *cb.ConfigValue { } } -func itemToValue(configItem *cb.ConfigItem) (string, *cb.ConfigValue) { - return configItem.Key, &cb.ConfigValue{Value: configItem.Value} +func groupToKeyValue(configGroup *cb.ConfigGroup) (string, *cb.ConfigValue) { + for key, value := range configGroup.Groups[GroupKey].Values { + return key, value + } + panic("No value encoded") } func TestInterface(t *testing.T) { @@ -92,7 +95,7 @@ func TestAnchorPeers(t *testing.T) { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(itemToValue(validMessage)) + err = m.ProposeConfig(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } diff --git a/common/configtx/handlers/application/sharedconfig_util.go b/common/configtx/handlers/application/sharedconfig_util.go index 9075ab4c865..ba2f7d38d2c 100644 --- a/common/configtx/handlers/application/sharedconfig_util.go +++ b/common/configtx/handlers/application/sharedconfig_util.go @@ -24,16 +24,21 @@ import ( var defaultAnchorPeers = []*pb.AnchorPeer{} -// TemplateAnchorPeers creates a headerless config item representing the anchor peers -func TemplateAnchorPeers(anchorPeers []*pb.AnchorPeer) *cb.ConfigItem { - return &cb.ConfigItem{ - Type: cb.ConfigItem_PEER, - Key: AnchorPeersKey, - Value: utils.MarshalOrPanic(&pb.AnchorPeers{AnchorPeers: anchorPeers}), +func configGroup(key string, value []byte) *cb.ConfigGroup { + result := cb.NewConfigGroup() + result.Groups[GroupKey] = cb.NewConfigGroup() + result.Groups[GroupKey].Values[key] = &cb.ConfigValue{ + Value: value, } + return result +} + +// TemplateAnchorPeers creates a headerless config item representing the anchor peers +func TemplateAnchorPeers(anchorPeers []*pb.AnchorPeer) *cb.ConfigGroup { + return configGroup(AnchorPeersKey, utils.MarshalOrPanic(&pb.AnchorPeers{AnchorPeers: anchorPeers})) } // DefaultAnchorPeers creates a headerless config item for the default orderer addresses -func DefaultAnchorPeers() *cb.ConfigItem { +func DefaultAnchorPeers() *cb.ConfigGroup { return TemplateAnchorPeers(defaultAnchorPeers) } diff --git a/common/configtx/handlers/application/template_test.go b/common/configtx/handlers/application/template_test.go deleted file mode 100644 index ea6b4b14035..00000000000 --- a/common/configtx/handlers/application/template_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* -Copyright IBM Corp. 2017 All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package application_test - -import ( - "testing" - - . "github.com/hyperledger/fabric/common/configtx/handlers/application" - configtxtest "github.com/hyperledger/fabric/common/configtx/test" -) - -func TestTemplate(t *testing.T) { - configtxtest.WriteTemplate(configtxtest.PeerTemplateName, DefaultAnchorPeers()) -} diff --git a/peer/channel/create.go b/peer/channel/create.go index 1b4e3b3d782..902f837afd7 100644 --- a/peer/channel/create.go +++ b/peer/channel/create.go @@ -55,7 +55,7 @@ func sendCreateChainTransaction(cf *ChannelCmdFactory) error { //TODO this is a temporary hack until `orderer.template` and 'msp.template' is supplied from the CLI oTemplate := configtxtest.OrdererTemplate() mspTemplate := configtxtest.MSPTemplate() - gossTemplate := configtx.NewSimpleTemplate(configtxapplication.TemplateAnchorPeers(anchorPeers)) + gossTemplate := configtx.NewSimpleTemplateNext(configtxapplication.TemplateAnchorPeers(anchorPeers)) chCrtTemp := configtx.NewCompositeTemplate(oTemplate, mspTemplate, gossTemplate) signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity()