Skip to content

Commit 8b20459

Browse files
author
Jason Yellick
committed
[FAB-2335] Move channel config to common Proposer
https://jira.hyperledger.org/browse/FAB-2335 This is the first in a series of CRs which will migrate the config value handlers off of their own custom transcation handling code and onto the common Proposer code. This will not only reduce the amount of reimplimented logic (and corresponding bugs) but also eventually facilitate two way config translation for the configtxgen tool. Change-Id: I81b07e3d0fb322fe9f4397b8e70273a9155f8e58 Signed-off-by: Jason Yellick <[email protected]>
1 parent 30a0e21 commit 8b20459

File tree

19 files changed

+330
-415
lines changed

19 files changed

+330
-415
lines changed

common/configtx/api/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package api
1818

1919
import (
2020
configvalues "github.com/hyperledger/fabric/common/configvalues"
21-
configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel"
21+
config "github.com/hyperledger/fabric/common/configvalues/root"
2222
"github.com/hyperledger/fabric/common/policies"
2323
"github.com/hyperledger/fabric/msp"
2424
cb "github.com/hyperledger/fabric/protos/common"
@@ -52,7 +52,7 @@ type Resources interface {
5252
PolicyManager() policies.Manager
5353

5454
// ChannelConfig returns the ChannelConfig for the chain
55-
ChannelConfig() configvalueschannel.ConfigReader
55+
ChannelConfig() config.ChannelValues
5656

5757
// OrdererConfig returns the configtxorderer.SharedConfig for the channel
5858
OrdererConfig() configvalues.Orderer

common/configtx/initializer.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ import (
2222
"github.com/hyperledger/fabric/common/cauthdsl"
2323
"github.com/hyperledger/fabric/common/configtx/api"
2424
configvaluesapi "github.com/hyperledger/fabric/common/configvalues"
25-
configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel"
2625
configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp"
27-
configvaluesroot "github.com/hyperledger/fabric/common/configvalues/root"
26+
config "github.com/hyperledger/fabric/common/configvalues/root"
2827
"github.com/hyperledger/fabric/common/policies"
2928
"github.com/hyperledger/fabric/msp"
3029
cb "github.com/hyperledger/fabric/protos/common"
3130
)
3231

3332
type resources struct {
3433
policyManager *policies.ManagerImpl
35-
configRoot *configvaluesroot.Root
34+
configRoot *config.Root
3635
mspConfigHandler *configtxmsp.MSPConfigHandler
3736
}
3837

@@ -42,7 +41,7 @@ func (r *resources) PolicyManager() policies.Manager {
4241
}
4342

4443
// ChannelConfig returns the api.ChannelConfig for the chain
45-
func (r *resources) ChannelConfig() configvalueschannel.ConfigReader {
44+
func (r *resources) ChannelConfig() config.ChannelValues {
4645
return r.configRoot.Channel()
4746
}
4847

@@ -79,7 +78,7 @@ func newResources() *resources {
7978

8079
return &resources{
8180
policyManager: policies.NewManagerImpl(RootGroupKey, policyProviderMap),
82-
configRoot: configvaluesroot.NewRoot(mspConfigHandler),
81+
configRoot: config.NewRoot(mspConfigHandler),
8382
mspConfigHandler: mspConfigHandler,
8483
}
8584
}

common/configtx/manager.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var (
4040
}
4141
)
4242

43-
type config struct {
43+
type configSet struct {
4444
channelID string
4545
sequence uint64
4646
configMap map[string]comparable
@@ -50,7 +50,7 @@ type configManager struct {
5050
api.Resources
5151
callOnUpdate []func(api.Manager)
5252
initializer api.Initializer
53-
current *config
53+
current *configSet
5454
}
5555

5656
// validateChainID makes sure that proposed chain IDs (i.e. channel names)
@@ -110,7 +110,7 @@ func NewManagerImpl(envConfig *cb.Envelope, initializer api.Initializer, callOnU
110110
cm := &configManager{
111111
Resources: initializer,
112112
initializer: initializer,
113-
current: &config{
113+
current: &configSet{
114114
sequence: configEnv.Config.Sequence,
115115
configMap: configMap,
116116
channelID: header.ChannelId,
@@ -234,7 +234,7 @@ func (cm *configManager) Apply(configEnv *cb.ConfigEnvelope) error {
234234
result.commit()
235235
cm.commitCallbacks()
236236

237-
cm.current = &config{
237+
cm.current = &configSet{
238238
configMap: configMap,
239239
channelID: cm.current.channelID,
240240
sequence: configEnv.Config.Sequence,

common/configtx/tool/provisional/provisional.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import (
2222
"github.com/hyperledger/fabric/common/cauthdsl"
2323
"github.com/hyperledger/fabric/common/configtx"
2424
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
25-
configtxchannel "github.com/hyperledger/fabric/common/configvalues/channel"
2625
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
2726
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
2827
configvaluesmsp "github.com/hyperledger/fabric/common/configvalues/msp"
28+
config "github.com/hyperledger/fabric/common/configvalues/root"
2929
"github.com/hyperledger/fabric/common/genesis"
3030
"github.com/hyperledger/fabric/common/policies"
3131
"github.com/hyperledger/fabric/msp"
@@ -83,9 +83,9 @@ func New(conf *genesisconfig.Profile) Generator {
8383
bs := &bootstrapper{
8484
channelGroups: []*cb.ConfigGroup{
8585
// Chain Config Types
86-
configtxchannel.DefaultHashingAlgorithm(),
87-
configtxchannel.DefaultBlockDataHashingStructure(),
88-
configtxchannel.TemplateOrdererAddresses(conf.Orderer.Addresses), // TODO, move to conf.Channel when it exists
86+
config.DefaultHashingAlgorithm(),
87+
config.DefaultBlockDataHashingStructure(),
88+
config.TemplateOrdererAddresses(conf.Orderer.Addresses), // TODO, move to conf.Channel when it exists
8989

9090
// Default policies
9191
policies.TemplateImplicitMetaAnyPolicy([]string{}, configvaluesmsp.ReadersPolicyKey),

common/configtx/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/hyperledger/fabric/protos/utils"
2525
)
2626

27-
func (c *config) verifyReadSet(readSet map[string]comparable) error {
27+
func (c *configSet) verifyReadSet(readSet map[string]comparable) error {
2828
for key, value := range readSet {
2929
existing, ok := c.configMap[key]
3030
if !ok {

common/configtx/update_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
)
2929

3030
func TestReadSetNotPresent(t *testing.T) {
31-
cm := &config{
31+
cm := &configSet{
3232
configMap: make(map[string]comparable),
3333
}
3434

@@ -43,7 +43,7 @@ func TestReadSetNotPresent(t *testing.T) {
4343
}
4444

4545
func TestReadSetBackVersioned(t *testing.T) {
46-
cm := &config{
46+
cm := &configSet{
4747
configMap: make(map[string]comparable),
4848
}
4949

@@ -79,7 +79,7 @@ func TestVerifyDeltaSet(t *testing.T) {
7979
Policy: &mockpolicies.Policy{},
8080
},
8181
},
82-
current: &config{
82+
current: &configSet{
8383
configMap: make(map[string]comparable),
8484
},
8585
}

common/configvalues/channel/config.go

-204
This file was deleted.

0 commit comments

Comments
 (0)