Skip to content

Commit 5ed12d2

Browse files
author
Jason Yellick
committed
[FAB-2074] Make config protos consistent in naming
https://jira.hyperledger.org/browse/FAB-2074 There are some pieces of the configuration transaction which refer to Configuration and others which refer to Config, this normalizes things. Change-Id: Ib8ef14d7b06f85e42536574f272b89f587203a67 Signed-off-by: Jason Yellick <[email protected]>
1 parent f8e86df commit 5ed12d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+620
-622
lines changed

common/cauthdsl/policy_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func makePolicySource(policyResult bool) []byte {
5959

6060
func addPolicy(manager *policies.ManagerImpl, id string, policy []byte) {
6161
manager.BeginConfig()
62-
err := manager.ProposeConfig(&cb.ConfigurationItem{
63-
Type: cb.ConfigurationItem_Policy,
62+
err := manager.ProposeConfig(&cb.ConfigItem{
63+
Type: cb.ConfigItem_Policy,
6464
Key: id,
6565
Value: policy,
6666
})

common/cauthdsl/policy_util.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222
)
2323

2424
// TemplatePolicy creates a headerless configuration item representing a policy for a given key
25-
func TemplatePolicy(key string, sigPolicyEnv *cb.SignaturePolicyEnvelope) *cb.ConfigurationItem {
26-
return &cb.ConfigurationItem{
27-
Type: cb.ConfigurationItem_Policy,
25+
func TemplatePolicy(key string, sigPolicyEnv *cb.SignaturePolicyEnvelope) *cb.ConfigItem {
26+
return &cb.ConfigItem{
27+
Type: cb.ConfigItem_Policy,
2828
Key: key,
2929
Value: utils.MarshalOrPanic(&cb.Policy{
3030
Type: int32(cb.Policy_SIGNATURE),

common/chainconfig/chainconfig.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ import (
2929

3030
// Chain config keys
3131
const (
32-
// HashingAlgorithmKey is the cb.ConfigurationItem type key name for the HashingAlgorithm message
32+
// HashingAlgorithmKey is the cb.ConfigItem type key name for the HashingAlgorithm message
3333
HashingAlgorithmKey = "HashingAlgorithm"
3434

35-
// BlockDataHashingStructureKey is the cb.ConfigurationItem type key name for the BlockDataHashingStructure message
35+
// BlockDataHashingStructureKey is the cb.ConfigItem type key name for the BlockDataHashingStructure message
3636
BlockDataHashingStructureKey = "BlockDataHashingStructure"
3737

38-
// OrdererAddressesKey is the cb.ConfigurationItem type key name for the OrdererAddresses message
38+
// OrdererAddressesKey is the cb.ConfigItem type key name for the OrdererAddresses message
3939
OrdererAddressesKey = "OrdererAddresses"
4040
)
4141

@@ -47,10 +47,10 @@ const (
4747

4848
var logger = logging.MustGetLogger("common/chainconfig")
4949

50-
// Descriptor stores the common chain configuration
50+
// Descriptor stores the common chain config
5151
// It is intended to be the primary accessor of DescriptorImpl
5252
// It is intended to discourage use of the other exported DescriptorImpl methods
53-
// which are used for updating the chain configuration by the configtx.Manager
53+
// which are used for updating the chain config by the configtx.Manager
5454
type Descriptor interface {
5555
// HashingAlgorithm returns the default algorithm to be used when hashing
5656
// such as computing block hashes, and CreationPolicy digests
@@ -99,20 +99,20 @@ func (pm *DescriptorImpl) OrdererAddresses() []string {
9999
return pm.config.ordererAddresses
100100
}
101101

102-
// BeginConfig is used to start a new configuration proposal
102+
// BeginConfig is used to start a new config proposal
103103
func (pm *DescriptorImpl) BeginConfig() {
104104
if pm.pendingConfig != nil {
105105
logger.Panicf("Programming error, cannot call begin in the middle of a proposal")
106106
}
107107
pm.pendingConfig = &chainConfig{}
108108
}
109109

110-
// RollbackConfig is used to abandon a new configuration proposal
110+
// RollbackConfig is used to abandon a new config proposal
111111
func (pm *DescriptorImpl) RollbackConfig() {
112112
pm.pendingConfig = nil
113113
}
114114

115-
// CommitConfig is used to commit a new configuration proposal
115+
// CommitConfig is used to commit a new config proposal
116116
func (pm *DescriptorImpl) CommitConfig() {
117117
if pm.pendingConfig == nil {
118118
logger.Panicf("Programming error, cannot call commit without an existing proposal")
@@ -121,10 +121,10 @@ func (pm *DescriptorImpl) CommitConfig() {
121121
pm.pendingConfig = nil
122122
}
123123

124-
// ProposeConfig is used to add new configuration to the configuration proposal
125-
func (pm *DescriptorImpl) ProposeConfig(configItem *cb.ConfigurationItem) error {
126-
if configItem.Type != cb.ConfigurationItem_Chain {
127-
return fmt.Errorf("Expected type of ConfigurationItem_Chain, got %v", configItem.Type)
124+
// ProposeConfig is used to add new config to the config proposal
125+
func (pm *DescriptorImpl) ProposeConfig(configItem *cb.ConfigItem) error {
126+
if configItem.Type != cb.ConfigItem_Chain {
127+
return fmt.Errorf("Expected type of ConfigItem_Chain, got %v", configItem.Type)
128128
}
129129

130130
switch configItem.Key {
@@ -157,7 +157,7 @@ func (pm *DescriptorImpl) ProposeConfig(configItem *cb.ConfigurationItem) error
157157
}
158158
pm.pendingConfig.ordererAddresses = ordererAddresses.Addresses
159159
default:
160-
logger.Warningf("Uknown Chain configuration item with key %s", configItem.Key)
160+
logger.Warningf("Uknown Chain config item with key %s", configItem.Key)
161161
}
162162
return nil
163163
}

common/chainconfig/chainconfig_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ func init() {
2929
logging.SetLevel(logging.DEBUG, "")
3030
}
3131

32-
func makeInvalidConfigItem(key string) *cb.ConfigurationItem {
33-
return &cb.ConfigurationItem{
34-
Type: cb.ConfigurationItem_Chain,
32+
func makeInvalidConfigItem(key string) *cb.ConfigItem {
33+
return &cb.ConfigItem{
34+
Type: cb.ConfigItem_Chain,
3535
Key: key,
3636
Value: []byte("Garbage Data"),
3737
}

common/chainconfig/chainconfig_util.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,49 @@ import (
2525

2626
const defaultHashingAlgorithm = SHA3Shake256
2727

28-
// TemplateHashingAlgorithm creates a headerless configuration item representing the hashing algorithm
29-
func TemplateHashingAlgorithm(name string) *cb.ConfigurationItem {
30-
return &cb.ConfigurationItem{
31-
Type: cb.ConfigurationItem_Chain,
28+
// TemplateHashingAlgorithm creates a headerless config item representing the hashing algorithm
29+
func TemplateHashingAlgorithm(name string) *cb.ConfigItem {
30+
return &cb.ConfigItem{
31+
Type: cb.ConfigItem_Chain,
3232
Key: HashingAlgorithmKey,
3333
Value: utils.MarshalOrPanic(&cb.HashingAlgorithm{Name: name}),
3434
}
3535

3636
}
3737

38-
// DefaultHashingAlgorithm creates a headerless configuration item for the default hashing algorithm
39-
func DefaultHashingAlgorithm() *cb.ConfigurationItem {
38+
// DefaultHashingAlgorithm creates a headerless config item for the default hashing algorithm
39+
func DefaultHashingAlgorithm() *cb.ConfigItem {
4040
return TemplateHashingAlgorithm(defaultHashingAlgorithm)
4141
}
4242

4343
const defaultBlockDataHashingStructureWidth = math.MaxUint32
4444

45-
// TemplateBlockDataHashingStructure creates a headerless configuration item representing the block data hashing structure
46-
func TemplateBlockDataHashingStructure(width uint32) *cb.ConfigurationItem {
47-
return &cb.ConfigurationItem{
48-
Type: cb.ConfigurationItem_Chain,
45+
// TemplateBlockDataHashingStructure creates a headerless config item representing the block data hashing structure
46+
func TemplateBlockDataHashingStructure(width uint32) *cb.ConfigItem {
47+
return &cb.ConfigItem{
48+
Type: cb.ConfigItem_Chain,
4949
Key: BlockDataHashingStructureKey,
5050
Value: utils.MarshalOrPanic(&cb.BlockDataHashingStructure{Width: width}),
5151
}
5252
}
5353

54-
// DefaultBlockDatahashingStructure creates a headerless configuration item for the default block data hashing structure
55-
func DefaultBlockDataHashingStructure() *cb.ConfigurationItem {
54+
// DefaultBlockDatahashingStructure creates a headerless config item for the default block data hashing structure
55+
func DefaultBlockDataHashingStructure() *cb.ConfigItem {
5656
return TemplateBlockDataHashingStructure(defaultBlockDataHashingStructureWidth)
5757
}
5858

5959
var defaultOrdererAddresses = []string{"127.0.0.1:7050"}
6060

61-
// TemplateOrdererAddressess creates a headerless configuration item representing the orderer addresses
62-
func TemplateOrdererAddresses(addresses []string) *cb.ConfigurationItem {
63-
return &cb.ConfigurationItem{
64-
Type: cb.ConfigurationItem_Chain,
61+
// TemplateOrdererAddressess creates a headerless config item representing the orderer addresses
62+
func TemplateOrdererAddresses(addresses []string) *cb.ConfigItem {
63+
return &cb.ConfigItem{
64+
Type: cb.ConfigItem_Chain,
6565
Key: OrdererAddressesKey,
6666
Value: utils.MarshalOrPanic(&cb.OrdererAddresses{Addresses: addresses}),
6767
}
6868
}
6969

70-
// DefaultOrdererAddresses creates a headerless configuration item for the default orderer addresses
71-
func DefaultOrdererAddresses() *cb.ConfigurationItem {
70+
// DefaultOrdererAddresses creates a headerless config item for the default orderer addresses
71+
func DefaultOrdererAddresses() *cb.ConfigItem {
7272
return TemplateOrdererAddresses(defaultOrdererAddresses)
7373
}

common/configtx/bytes_handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (bh *BytesHandler) CommitConfig() {
5656
}
5757

5858
// ProposeConfig called when config is added to a proposal
59-
func (bh *BytesHandler) ProposeConfig(configItem *cb.ConfigurationItem) error {
59+
func (bh *BytesHandler) ProposeConfig(configItem *cb.ConfigItem) error {
6060
bh.proposed[configItem.Key] = configItem.Value
6161
return nil
6262
}

common/configtx/filter.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ func NewFilter(manager Manager) filter.Rule {
3838

3939
type configCommitter struct {
4040
manager Manager
41-
configEnvelope *cb.ConfigurationEnvelope
41+
configEnvelope *cb.ConfigEnvelope
4242
}
4343

4444
func (cc *configCommitter) Commit() {
4545
err := cc.manager.Apply(cc.configEnvelope)
4646
if err != nil {
47-
panic(fmt.Errorf("Could not apply configuration transaction which should have already been validated: %s", err))
47+
panic(fmt.Errorf("Could not apply config transaction which should have already been validated: %s", err))
4848
}
4949
}
5050

@@ -65,7 +65,7 @@ func (cf *configFilter) Apply(message *cb.Envelope) (filter.Action, filter.Commi
6565
return filter.Forward, nil
6666
}
6767

68-
config := &cb.ConfigurationEnvelope{}
68+
config := &cb.ConfigEnvelope{}
6969
err = proto.Unmarshal(msgData.Data, config)
7070
if err != nil {
7171
return filter.Reject, nil

common/configtx/filter_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ import (
3131

3232
type mockConfigManager struct {
3333
mockconfigtx.Manager
34-
applied *cb.ConfigurationEnvelope
34+
applied *cb.ConfigEnvelope
3535
err error
3636
}
3737

38-
func (mcm *mockConfigManager) Validate(configtx *cb.ConfigurationEnvelope) error {
38+
func (mcm *mockConfigManager) Validate(configtx *cb.ConfigEnvelope) error {
3939
return mcm.err
4040
}
4141

42-
func (mcm *mockConfigManager) Apply(configtx *cb.ConfigurationEnvelope) error {
42+
func (mcm *mockConfigManager) Apply(configtx *cb.ConfigEnvelope) error {
4343
mcm.applied = configtx
4444
return mcm.err
4545
}
@@ -65,31 +65,31 @@ func TestForwardNonConfig(t *testing.T) {
6565
func TestAcceptGoodConfig(t *testing.T) {
6666
mcm := &mockConfigManager{}
6767
cf := NewFilter(mcm)
68-
configEnv := &cb.ConfigurationEnvelope{}
68+
configEnv := &cb.ConfigEnvelope{}
6969
config, _ := proto.Marshal(configEnv)
7070
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChainHeader: &cb.ChainHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
7171
configEnvelope := &cb.Envelope{
7272
Payload: configBytes,
7373
}
7474
result, committer := cf.Apply(configEnvelope)
7575
if result != filter.Accept {
76-
t.Fatal("Should have indicated a good config message causes a reconfiguration")
76+
t.Fatal("Should have indicated a good config message causes a reconfig")
7777
}
7878

7979
if !committer.Isolated() {
80-
t.Fatal("Configuration transactions should be isolated to their own block")
80+
t.Fatal("Config transactions should be isolated to their own block")
8181
}
8282

8383
committer.Commit()
8484

8585
if !reflect.DeepEqual(mcm.applied, configEnv) {
86-
t.Fatalf("Should have applied new configuration on commit got %v and %v", mcm.applied, configEnv)
86+
t.Fatalf("Should have applied new config on commit got %v and %v", mcm.applied, configEnv)
8787
}
8888
}
8989

9090
func TestRejectBadConfig(t *testing.T) {
9191
cf := NewFilter(&mockConfigManager{err: fmt.Errorf("Error")})
92-
config, _ := proto.Marshal(&cb.ConfigurationEnvelope{})
92+
config, _ := proto.Marshal(&cb.ConfigEnvelope{})
9393
configBytes, _ := proto.Marshal(&cb.Payload{Header: &cb.Header{ChainHeader: &cb.ChainHeader{Type: int32(cb.HeaderType_CONFIGURATION_TRANSACTION)}}, Data: config})
9494
result, _ := cf.Apply(&cb.Envelope{
9595
Payload: configBytes,

common/configtx/inspector/common_types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"github.com/golang/protobuf/proto"
2424
)
2525

26-
func viewableConfigurationEnvelope(name string, configEnvelope *cb.ConfigurationEnvelope) Viewable {
26+
func viewableConfigEnvelope(name string, configEnvelope *cb.ConfigEnvelope) Viewable {
2727
return &field{
2828
name: name,
29-
values: []Viewable{viewableConfig("Config", configEnvelope.Config), viewableConfigurationSignatureSlice("Signatures", configEnvelope.Signatures)},
29+
values: []Viewable{viewableConfig("Config", configEnvelope.Config), viewableConfigSignatureSlice("Signatures", configEnvelope.Signatures)},
3030
}
3131
}
3232

@@ -38,26 +38,26 @@ func viewableConfig(name string, configBytes []byte) Viewable {
3838
}
3939
values := make([]Viewable, len(config.Items))
4040
for i, item := range config.Items {
41-
values[i] = viewableConfigurationItem(fmt.Sprintf("Element %d", i), item)
41+
values[i] = viewableConfigItem(fmt.Sprintf("Element %d", i), item)
4242
}
4343
return &field{
4444
name: name,
4545
values: values,
4646
}
4747
}
4848

49-
func viewableConfigurationSignatureSlice(name string, configSigs []*cb.ConfigurationSignature) Viewable {
49+
func viewableConfigSignatureSlice(name string, configSigs []*cb.ConfigSignature) Viewable {
5050
values := make([]Viewable, len(configSigs))
5151
for i, item := range configSigs {
52-
values[i] = viewableConfigurationSignature(fmt.Sprintf("Element %d", i), item)
52+
values[i] = viewableConfigSignature(fmt.Sprintf("Element %d", i), item)
5353
}
5454
return &field{
5555
name: name,
5656
values: values,
5757
}
5858
}
5959

60-
func viewableConfigurationSignature(name string, configSig *cb.ConfigurationSignature) Viewable {
60+
func viewableConfigSignature(name string, configSig *cb.ConfigSignature) Viewable {
6161
children := make([]Viewable, 2)
6262

6363
sigHeader := &cb.SignatureHeader{}
@@ -83,7 +83,7 @@ func viewableSignatureHeader(name string, sh *cb.SignatureHeader) Viewable {
8383
}
8484
}
8585

86-
func viewableConfigurationItem(name string, ci *cb.ConfigurationItem) Viewable {
86+
func viewableConfigItem(name string, ci *cb.ConfigItem) Viewable {
8787

8888
values := make([]Viewable, 6) // Type, Key, Header, LastModified, ModificationPolicy, Value
8989
values[0] = viewableString("Type", fmt.Sprintf("%v", ci.Type))

common/configtx/inspector/inspector.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
cb "github.com/hyperledger/fabric/protos/common"
2222
)
2323

24-
var typeMap map[cb.ConfigurationItem_ConfigurationType]ConfigurationItemValueLens = make(map[cb.ConfigurationItem_ConfigurationType]ConfigurationItemValueLens)
24+
var typeMap map[cb.ConfigItem_ConfigType]ConfigItemValueLens = make(map[cb.ConfigItem_ConfigType]ConfigItemValueLens)
2525

26-
type ConfigurationItemValueLens interface {
26+
type ConfigItemValueLens interface {
2727
// Value takes a config item and returns a Viewable version of its value
28-
Value(configItem *cb.ConfigurationItem) Viewable
28+
Value(configItem *cb.ConfigItem) Viewable
2929
}
3030

3131
type Viewable interface {
@@ -55,7 +55,7 @@ func printViewable(viewable Viewable, curDepth int) {
5555
}
5656
}
5757

58-
func PrintConfiguration(configEnvelope *cb.ConfigurationEnvelope) {
59-
viewable := viewableConfigurationEnvelope("ConfigurationEnvelope", configEnvelope)
58+
func PrintConfig(configEnvelope *cb.ConfigEnvelope) {
59+
viewable := viewableConfigEnvelope("ConfigEnvelope", configEnvelope)
6060
printViewable(viewable, 0)
6161
}

common/configtx/inspector/inspector_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ func TestFromTemplate(t *testing.T) {
2828
if err != nil {
2929
t.Fatalf("Error creating signed items: %s", err)
3030
}
31-
PrintConfiguration(configEnvelope)
31+
PrintConfig(configEnvelope)
3232
}

common/configtx/inspector/orderer_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
)
2626

2727
// This file contains the functions needed to create Viewables for protos defined in
28-
// the orderer configuration proto
28+
// the orderer config proto
2929

3030
type ordererTypes struct{}
3131

32-
func (ot ordererTypes) Value(configItem *cb.ConfigurationItem) Viewable {
32+
func (ot ordererTypes) Value(configItem *cb.ConfigItem) Viewable {
3333
name := "Value"
3434
switch configItem.Key {
3535
case "ConsensusType":
@@ -147,5 +147,5 @@ func viewableBatchSize(name string, batchSize *ab.BatchSize) Viewable {
147147
}
148148

149149
func init() {
150-
typeMap[cb.ConfigurationItem_Orderer] = ordererTypes{}
150+
typeMap[cb.ConfigItem_Orderer] = ordererTypes{}
151151
}

common/configtx/inspector/policy_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
type policyTypes struct{}
2828

29-
func (ot policyTypes) Value(configItem *cb.ConfigurationItem) Viewable {
29+
func (ot policyTypes) Value(configItem *cb.ConfigItem) Viewable {
3030
name := "Value"
3131
value := &cb.Policy{}
3232
if err := proto.Unmarshal(configItem.Value, value); err != nil {
@@ -59,5 +59,5 @@ func viewableSignaturePolicyEnvelope(name string, signaturePolicyEnvelope *cb.Si
5959
}
6060

6161
func init() {
62-
typeMap[cb.ConfigurationItem_Policy] = policyTypes{}
62+
typeMap[cb.ConfigItem_Policy] = policyTypes{}
6363
}

0 commit comments

Comments
 (0)