Skip to content

Commit 28e0d18

Browse files
author
Jason Yellick
committed
[FAB-2172] Remove '*Next' from Config
https://jira.hyperledger.org/browse/FAB-2172 This CR removes the 'Next' suffix which was used to qualify the newer Config structures while in development. Now that the old structures have been removed, the Next suffix can be removed as the newer protos are now the only ones used. Change-Id: Ie3cd138fd905bc5b330d8c6372c0dea108a29c7d Signed-off-by: Jason Yellick <[email protected]>
1 parent 6434844 commit 28e0d18

File tree

14 files changed

+81
-83
lines changed

14 files changed

+81
-83
lines changed

common/configtx/manager.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func computeSequence(configGroup *cb.ConfigGroup) uint64 {
7979

8080
// computeChannelIdAndSequence returns the chain id and the sequence number for a config envelope
8181
// or an error if there is a problem with the config envelope
82-
func computeChannelIdAndSequence(config *cb.ConfigNext) (string, uint64, error) {
82+
func computeChannelIdAndSequence(config *cb.Config) (string, uint64, error) {
8383
if config.Channel == nil {
8484
return "", 0, errors.New("Empty envelope unsupported")
8585
}
@@ -134,7 +134,7 @@ func validateChainID(chainID string) error {
134134
}
135135

136136
func NewManagerImpl(configtx *cb.ConfigEnvelope, initializer api.Initializer, callOnUpdate []func(api.Manager)) (api.Manager, error) {
137-
config, err := UnmarshalConfigNext(configtx.Config)
137+
config, err := UnmarshalConfig(configtx.Config)
138138
if err != nil {
139139
return nil, err
140140
}
@@ -240,7 +240,7 @@ func (cm *configManager) recurseConfig(result map[string]comparable, path []stri
240240
}
241241

242242
func (cm *configManager) processConfig(configtx *cb.ConfigEnvelope) (configMap map[string]comparable, err error) {
243-
config, err := UnmarshalConfigNext(configtx.Config)
243+
config, err := UnmarshalConfig(configtx.Config)
244244
if err != nil {
245245
return nil, err
246246
}

common/configtx/manager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func makeMarshaledConfig(chainID string, configPairs ...*configPair) []byte {
6262
values[pair.key] = pair.value
6363
}
6464

65-
config := &cb.ConfigNext{
65+
config := &cb.Config{
6666
Header: &cb.ChannelHeader{ChannelId: chainID},
6767
Channel: &cb.ConfigGroup{
6868
Values: values,
@@ -438,7 +438,7 @@ func TestInvalidProposal(t *testing.T) {
438438
func TestMissingHeader(t *testing.T) {
439439
group := cb.NewConfigGroup()
440440
group.Values["foo"] = &cb.ConfigValue{}
441-
data := utils.MarshalOrPanic(&cb.ConfigNext{Channel: group})
441+
data := utils.MarshalOrPanic(&cb.Config{Channel: group})
442442
_, err := NewManagerImpl(&cb.ConfigEnvelope{
443443
Config: data,
444444
}, defaultInitializer(), nil)

common/configtx/template.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ type Template interface {
4545
Envelope(chainID string) (*cb.ConfigEnvelope, error)
4646
}
4747

48-
type simpleTemplateNext struct {
48+
type simpleTemplate struct {
4949
configGroup *cb.ConfigGroup
5050
}
5151

52-
// NewSimpleTemplateNext creates a Template using the supplied ConfigGroup
53-
func NewSimpleTemplateNext(configGroups ...*cb.ConfigGroup) Template {
52+
// NewSimpleTemplate creates a Template using the supplied ConfigGroup
53+
func NewSimpleTemplate(configGroups ...*cb.ConfigGroup) Template {
5454
sts := make([]Template, len(configGroups))
5555
for i, group := range configGroups {
56-
sts[i] = &simpleTemplateNext{
56+
sts[i] = &simpleTemplate{
5757
configGroup: group,
5858
}
5959
}
6060
return NewCompositeTemplate(sts...)
6161
}
6262

6363
// Envelope returns a ConfigEnvelopes for the given chainID
64-
func (st *simpleTemplateNext) Envelope(chainID string) (*cb.ConfigEnvelope, error) {
65-
config, err := proto.Marshal(&cb.ConfigNext{
64+
func (st *simpleTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error) {
65+
config, err := proto.Marshal(&cb.Config{
6666
Header: &cb.ChannelHeader{
6767
ChannelId: chainID,
6868
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
@@ -128,7 +128,7 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error
128128
if err != nil {
129129
return nil, err
130130
}
131-
config, err := UnmarshalConfigNext(configEnv.Config)
131+
config, err := UnmarshalConfig(configEnv.Config)
132132
if err != nil {
133133
return nil, err
134134
}
@@ -138,7 +138,7 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigEnvelope, error
138138
}
139139
}
140140

141-
marshaledConfig, err := proto.Marshal(&cb.ConfigNext{
141+
marshaledConfig, err := proto.Marshal(&cb.Config{
142142
Header: &cb.ChannelHeader{
143143
ChannelId: chainID,
144144
Type: int32(cb.HeaderType_CONFIGURATION_ITEM),
@@ -164,7 +164,7 @@ func NewChainCreationTemplate(creationPolicy string, template Template) Template
164164
}),
165165
}
166166

167-
return NewCompositeTemplate(NewSimpleTemplateNext(result), template)
167+
return NewCompositeTemplate(NewSimpleTemplate(result), template)
168168
}
169169

170170
// MakeChainCreationTransaction is a handy utility function for creating new chain transactions using the underlying Template framework

common/configtx/template_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func verifyItemsResult(t *testing.T, template Template, count int) {
3434
t.Fatalf("Should not have errored: %s", err)
3535
}
3636

37-
configNext, err := UnmarshalConfigNext(configEnv.Config)
37+
configNext, err := UnmarshalConfig(configEnv.Config)
3838
if err != nil {
3939
t.Fatalf("Should not have errored: %s", err)
4040
}
@@ -54,7 +54,7 @@ func simpleGroup(index int) *cb.ConfigGroup {
5454
}
5555

5656
func TestSimpleTemplate(t *testing.T) {
57-
simple := NewSimpleTemplateNext(
57+
simple := NewSimpleTemplate(
5858
simpleGroup(0),
5959
simpleGroup(1),
6060
)
@@ -63,11 +63,11 @@ func TestSimpleTemplate(t *testing.T) {
6363

6464
func TestCompositeTemplate(t *testing.T) {
6565
composite := NewCompositeTemplate(
66-
NewSimpleTemplateNext(
66+
NewSimpleTemplate(
6767
simpleGroup(0),
6868
simpleGroup(1),
6969
),
70-
NewSimpleTemplateNext(
70+
NewSimpleTemplate(
7171
simpleGroup(2),
7272
),
7373
)
@@ -76,7 +76,7 @@ func TestCompositeTemplate(t *testing.T) {
7676
}
7777

7878
func TestNewChainTemplate(t *testing.T) {
79-
simple := NewSimpleTemplateNext(
79+
simple := NewSimpleTemplate(
8080
simpleGroup(0),
8181
simpleGroup(1),
8282
)
@@ -90,7 +90,7 @@ func TestNewChainTemplate(t *testing.T) {
9090
t.Fatalf("Error creation a chain creation config")
9191
}
9292

93-
configNext, err := UnmarshalConfigNext(configEnv.Config)
93+
configNext, err := UnmarshalConfig(configEnv.Config)
9494
if err != nil {
9595
t.Fatalf("Should not have errored: %s", err)
9696
}

common/configtx/test/helper.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ func MSPTemplate() configtx.Template {
9090
if err != nil {
9191
logger.Panicf("Could not load sample MSP config: %s", err)
9292
}
93-
return configtx.NewSimpleTemplateNext(configtxmsp.TemplateGroupMSP([]string{configtxapplication.GroupKey}, mspConf))
93+
return configtx.NewSimpleTemplate(configtxmsp.TemplateGroupMSP([]string{configtxapplication.GroupKey}, mspConf))
9494
}
9595

9696
// ApplicationTemplate returns the test application template
9797
func ApplicationTemplate() configtx.Template {
98-
return configtx.NewSimpleTemplateNext(configtxapplication.DefaultAnchorPeers())
98+
return configtx.NewSimpleTemplate(configtxapplication.DefaultAnchorPeers())
9999
}
100100

101101
// CompositeTemplate returns the composite template of peer, orderer, and MSP

common/configtx/tool/provisional/provisional.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ func New(conf *genesisconfig.TopLevel) Generator {
106106
}
107107

108108
func (bs *bootstrapper) ChannelTemplate() configtx.Template {
109-
return configtx.NewSimpleTemplateNext(bs.minimalGroups...)
109+
return configtx.NewSimpleTemplate(bs.minimalGroups...)
110110
}
111111

112112
func (bs *bootstrapper) GenesisBlock() *cb.Block {
113113
block, err := genesis.NewFactoryImpl(
114114
configtx.NewCompositeTemplate(
115-
configtx.NewSimpleTemplateNext(bs.systemChainGroups...),
115+
configtx.NewSimpleTemplate(bs.systemChainGroups...),
116116
bs.ChannelTemplate(),
117117
),
118118
).Block(TestChainID)

common/configtx/util.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525
"github.com/golang/protobuf/proto"
2626
)
2727

28-
// UnmarshalConfigNext attempts to unmarshal bytes to a *cb.ConfigNext
29-
func UnmarshalConfigNext(data []byte) (*cb.ConfigNext, error) {
30-
config := &cb.ConfigNext{}
28+
// UnmarshalConfig attempts to unmarshal bytes to a *cb.Config
29+
func UnmarshalConfig(data []byte) (*cb.Config, error) {
30+
config := &cb.Config{}
3131
err := proto.Unmarshal(data, config)
3232
if err != nil {
3333
return nil, err

common/genesis/genesis_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
func TestSanity(t *testing.T) {
26-
impl := NewFactoryImpl(configtx.NewSimpleTemplateNext())
26+
impl := NewFactoryImpl(configtx.NewSimpleTemplate())
2727
_, err := impl.Block("TestChainID")
2828
if err != nil {
2929
t.Fatalf("Basic sanity fails")

orderer/multichain/systemchain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (sc *systemChain) proposeChain(configTx *cb.Envelope) cb.Status {
148148
}
149149

150150
func (sc *systemChain) authorize(configEnvelope *cb.ConfigEnvelope) cb.Status {
151-
configNext := &cb.ConfigNext{}
151+
configNext := &cb.Config{}
152152
err := proto.Unmarshal(configEnvelope.Config, configNext)
153153
if err != nil {
154154
logger.Debugf("Failing to validate chain creation because of unmarshaling error: %s", err)

orderer/multichain/util_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func makeConfigTx(chainID string, i int) *cb.Envelope {
8787
group.Groups[configtxorderer.GroupKey].Values[fmt.Sprintf("%d", i)] = &cb.ConfigValue{
8888
Value: []byte(fmt.Sprintf("%d", i)),
8989
}
90-
configTemplate := configtx.NewSimpleTemplateNext(group)
90+
configTemplate := configtx.NewSimpleTemplate(group)
9191
configEnv, err := configTemplate.Envelope(chainID)
9292
if err != nil {
9393
panic(err)

peer/channel/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func sendCreateChainTransaction(cf *ChannelCmdFactory) error {
5555
//TODO this is a temporary hack until `orderer.template` and 'msp.template' is supplied from the CLI
5656
oTemplate := configtxtest.OrdererTemplate()
5757
mspTemplate := configtxtest.MSPTemplate()
58-
gossTemplate := configtx.NewSimpleTemplateNext(configtxapplication.TemplateAnchorPeers(anchorPeers))
58+
gossTemplate := configtx.NewSimpleTemplate(configtxapplication.TemplateAnchorPeers(anchorPeers))
5959
chCrtTemp := configtx.NewCompositeTemplate(oTemplate, mspTemplate, gossTemplate)
6060

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

protos/common/common.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configtx.pb.go

+46-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/common/configtx.proto

+3-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ package common;
4848
// 4. All configuration changes have a LastModification of one more than the last configuration's highest LastModification number
4949
// 5. All configuration changes satisfy the corresponding modification policy
5050
message ConfigEnvelope {
51-
bytes config = 1; // A marshaled ConfigNext structure
51+
bytes config = 1; // A marshaled Config structure
5252
repeated ConfigSignature signatures = 2; // Signatures over the config
5353
}
5454

@@ -62,9 +62,8 @@ message ConfigValueSchema {}
6262

6363
message ConfigPolicySchema {}
6464

65-
// XXX this structure is to allow us to minimize the diffs in this change series
66-
// it will be renamed Config once the original is ready to be removed
67-
message ConfigNext {
65+
// Config represents the config for a particular channel
66+
message Config {
6867
ChannelHeader header = 1;
6968
ConfigGroup channel = 2;
7069
}

0 commit comments

Comments
 (0)