Skip to content

Commit

Permalink
[FAB-2335] Move channel config to common Proposer
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Mar 7, 2017
1 parent 30a0e21 commit 8b20459
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 415 deletions.
4 changes: 2 additions & 2 deletions common/configtx/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package api

import (
configvalues "github.com/hyperledger/fabric/common/configvalues"
configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel"
config "github.com/hyperledger/fabric/common/configvalues/root"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/msp"
cb "github.com/hyperledger/fabric/protos/common"
Expand Down Expand Up @@ -52,7 +52,7 @@ type Resources interface {
PolicyManager() policies.Manager

// ChannelConfig returns the ChannelConfig for the chain
ChannelConfig() configvalueschannel.ConfigReader
ChannelConfig() config.ChannelValues

// OrdererConfig returns the configtxorderer.SharedConfig for the channel
OrdererConfig() configvalues.Orderer
Expand Down
9 changes: 4 additions & 5 deletions common/configtx/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ import (
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/configtx/api"
configvaluesapi "github.com/hyperledger/fabric/common/configvalues"
configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel"
configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp"
configvaluesroot "github.com/hyperledger/fabric/common/configvalues/root"
config "github.com/hyperledger/fabric/common/configvalues/root"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/msp"
cb "github.com/hyperledger/fabric/protos/common"
)

type resources struct {
policyManager *policies.ManagerImpl
configRoot *configvaluesroot.Root
configRoot *config.Root
mspConfigHandler *configtxmsp.MSPConfigHandler
}

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

// ChannelConfig returns the api.ChannelConfig for the chain
func (r *resources) ChannelConfig() configvalueschannel.ConfigReader {
func (r *resources) ChannelConfig() config.ChannelValues {
return r.configRoot.Channel()
}

Expand Down Expand Up @@ -79,7 +78,7 @@ func newResources() *resources {

return &resources{
policyManager: policies.NewManagerImpl(RootGroupKey, policyProviderMap),
configRoot: configvaluesroot.NewRoot(mspConfigHandler),
configRoot: config.NewRoot(mspConfigHandler),
mspConfigHandler: mspConfigHandler,
}
}
Expand Down
8 changes: 4 additions & 4 deletions common/configtx/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
}
)

type config struct {
type configSet struct {
channelID string
sequence uint64
configMap map[string]comparable
Expand All @@ -50,7 +50,7 @@ type configManager struct {
api.Resources
callOnUpdate []func(api.Manager)
initializer api.Initializer
current *config
current *configSet
}

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

cm.current = &config{
cm.current = &configSet{
configMap: configMap,
channelID: cm.current.channelID,
sequence: configEnv.Config.Sequence,
Expand Down
8 changes: 4 additions & 4 deletions common/configtx/tool/provisional/provisional.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"github.com/hyperledger/fabric/common/cauthdsl"
"github.com/hyperledger/fabric/common/configtx"
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
configtxchannel "github.com/hyperledger/fabric/common/configvalues/channel"
configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
configvaluesmsp "github.com/hyperledger/fabric/common/configvalues/msp"
config "github.com/hyperledger/fabric/common/configvalues/root"
"github.com/hyperledger/fabric/common/genesis"
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/msp"
Expand Down Expand Up @@ -83,9 +83,9 @@ func New(conf *genesisconfig.Profile) Generator {
bs := &bootstrapper{
channelGroups: []*cb.ConfigGroup{
// Chain Config Types
configtxchannel.DefaultHashingAlgorithm(),
configtxchannel.DefaultBlockDataHashingStructure(),
configtxchannel.TemplateOrdererAddresses(conf.Orderer.Addresses), // TODO, move to conf.Channel when it exists
config.DefaultHashingAlgorithm(),
config.DefaultBlockDataHashingStructure(),
config.TemplateOrdererAddresses(conf.Orderer.Addresses), // TODO, move to conf.Channel when it exists

// Default policies
policies.TemplateImplicitMetaAnyPolicy([]string{}, configvaluesmsp.ReadersPolicyKey),
Expand Down
2 changes: 1 addition & 1 deletion common/configtx/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/hyperledger/fabric/protos/utils"
)

func (c *config) verifyReadSet(readSet map[string]comparable) error {
func (c *configSet) verifyReadSet(readSet map[string]comparable) error {
for key, value := range readSet {
existing, ok := c.configMap[key]
if !ok {
Expand Down
6 changes: 3 additions & 3 deletions common/configtx/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

func TestReadSetNotPresent(t *testing.T) {
cm := &config{
cm := &configSet{
configMap: make(map[string]comparable),
}

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

func TestReadSetBackVersioned(t *testing.T) {
cm := &config{
cm := &configSet{
configMap: make(map[string]comparable),
}

Expand Down Expand Up @@ -79,7 +79,7 @@ func TestVerifyDeltaSet(t *testing.T) {
Policy: &mockpolicies.Policy{},
},
},
current: &config{
current: &configSet{
configMap: make(map[string]comparable),
},
}
Expand Down
204 changes: 0 additions & 204 deletions common/configvalues/channel/config.go

This file was deleted.

Loading

0 comments on commit 8b20459

Please sign in to comment.