From fee7c6cfe53ef1015fe2272b32b7bb8e6b42b071 Mon Sep 17 00:00:00 2001 From: Jason Yellick Date: Thu, 16 Feb 2017 15:59:24 -0500 Subject: [PATCH] [FAB-2312] configtx value handlers to own package https://jira.hyperledger.org/browse/FAB-2312 There used to be a single type for configuration, 'ConfigItem', but that has bifurcated into 'ConfigValue', 'ConfigGroup', and 'ConfigPolicy'. In order to handle the 'ConfigValue' and the 'ConfigPolicy' in similar ways, the 'ConfigValue' handling needs to be pushed out into its own package just like policy handling is. This CR accomplishes that. This is in preparation for treating the PolicyHandler as more of a first class object and to eliminate the need for hacky importing. Change-Id: I690a33e09843eb4c29611319f2e3942baae2dfdb Signed-off-by: Jason Yellick --- common/cauthdsl/policy_test.go | 2 +- common/configtx/api/api.go | 100 +++-------------- common/configtx/config.go | 13 ++- common/configtx/initializer.go | 35 +++--- common/configtx/template.go | 2 +- common/configtx/template_test.go | 2 +- common/configtx/test/helper.go | 6 +- .../configtx/tool/provisional/provisional.go | 4 +- common/configvalues/api/api.go | 103 ++++++++++++++++++ .../channel}/application/organization.go | 34 +++--- .../channel}/application/organization_test.go | 20 ++-- .../channel}/application/sharedconfig.go | 36 +++--- .../channel}/application/sharedconfig_test.go | 12 +- .../channel}/application/sharedconfig_util.go | 0 .../common/organization}/organization.go | 22 ++-- .../common/organization}/organization_test.go | 14 +-- .../channel}/orderer/sharedconfig.go | 32 +++--- .../channel}/orderer/sharedconfig_test.go | 98 ++++++++--------- .../channel}/orderer/sharedconfig_util.go | 0 .../channel/sharedconfig.go | 24 ++-- .../channel/sharedconfig_test.go | 40 +++---- .../channel/sharedconfig_util.go | 0 .../handlers => configvalues}/msp/config.go | 14 +-- .../msp/config_test.go | 4 +- .../msp/config_util.go | 0 common/mocks/configtx/configtx.go | 28 +++-- common/mocks/configtx/configtx_test.go | 4 - .../channel}/orderer/sharedconfig.go | 0 .../channel}/orderer/sharedconfig_test.go | 4 +- .../channel/sharedconfig.go | 0 .../channel/sharedconfig_test.go | 4 +- common/policies/policy.go | 8 +- core/peer/peer.go | 13 ++- gossip/service/eventer.go | 6 +- gossip/service/eventer_test.go | 16 +-- orderer/common/blockcutter/blockcutter.go | 6 +- .../common/blockcutter/blockcutter_test.go | 2 +- orderer/common/deliver/deliver.go | 4 +- orderer/common/deliver/deliver_test.go | 10 +- orderer/kafka/orderer_test.go | 24 ++-- orderer/mocks/multichain/multichain.go | 6 +- orderer/multichain/chainsupport.go | 4 +- orderer/multichain/manager.go | 3 +- orderer/multichain/systemchain.go | 8 +- orderer/multichain/systemchain_test.go | 18 +-- orderer/multichain/util_test.go | 2 +- orderer/solo/consensus_test.go | 10 +- peer/channel/create.go | 2 +- 48 files changed, 419 insertions(+), 380 deletions(-) create mode 100644 common/configvalues/api/api.go rename common/{configtx/handlers => configvalues/channel}/application/organization.go (73%) rename common/{configtx/handlers => configvalues/channel}/application/organization_test.go (76%) rename common/{configtx/handlers => configvalues/channel}/application/sharedconfig.go (73%) rename common/{configtx/handlers => configvalues/channel}/application/sharedconfig_test.go (87%) rename common/{configtx/handlers => configvalues/channel}/application/sharedconfig_util.go (100%) rename common/{configtx/handlers => configvalues/channel/common/organization}/organization.go (84%) rename common/{configtx/handlers => configvalues/channel/common/organization}/organization_test.go (85%) rename common/{configtx/handlers => configvalues/channel}/orderer/sharedconfig.go (91%) rename common/{configtx/handlers => configvalues/channel}/orderer/sharedconfig_test.go (78%) rename common/{configtx/handlers => configvalues/channel}/orderer/sharedconfig_util.go (100%) rename common/{configtx/handlers => configvalues}/channel/sharedconfig.go (87%) rename common/{configtx/handlers => configvalues}/channel/sharedconfig_test.go (80%) rename common/{configtx/handlers => configvalues}/channel/sharedconfig_util.go (100%) rename common/{configtx/handlers => configvalues}/msp/config.go (86%) rename common/{configtx/handlers => configvalues}/msp/config_test.go (92%) rename common/{configtx/handlers => configvalues}/msp/config_util.go (100%) rename common/mocks/{configtx/handlers => configvalues/channel}/orderer/sharedconfig.go (100%) rename common/mocks/{configtx/handlers => configvalues/channel}/orderer/sharedconfig_test.go (85%) rename common/mocks/{configtx/handlers => configvalues}/channel/sharedconfig.go (100%) rename common/mocks/{configtx/handlers => configvalues}/channel/sharedconfig_test.go (85%) diff --git a/common/cauthdsl/policy_test.go b/common/cauthdsl/policy_test.go index e1acf92e0d4..ffc226cfb65 100644 --- a/common/cauthdsl/policy_test.go +++ b/common/cauthdsl/policy_test.go @@ -64,7 +64,7 @@ func addPolicy(manager *policies.ManagerImpl, id string, policy *cb.Policy) { if err != nil { panic(err) } - manager.CommitConfig() + manager.CommitProposals() } func providerMap() map[int32]policies.Provider { diff --git a/common/configtx/api/api.go b/common/configtx/api/api.go index f91e38c15e5..2cdbe806a64 100644 --- a/common/configtx/api/api.go +++ b/common/configtx/api/api.go @@ -17,87 +17,12 @@ limitations under the License. package api import ( - "time" - + configvalues "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" - ab "github.com/hyperledger/fabric/protos/orderer" - pb "github.com/hyperledger/fabric/protos/peer" ) -// ChannelConfig stores the common channel config -type ChannelConfig interface { - // HashingAlgorithm returns the default algorithm to be used when hashing - // such as computing block hashes, and CreationPolicy digests - HashingAlgorithm() func(input []byte) []byte - - // BlockDataHashingStructureWidth returns the width to use when constructing the - // Merkle tree to compute the BlockData hash - BlockDataHashingStructureWidth() uint32 - - // OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver - OrdererAddresses() []string -} - -type OrgConfig interface { - // Name returns the name this org is referred to in config - Name() string - - // MSPID returns the MSP ID associated with this org - MSPID() string -} - -// ApplicationOrgConfig stores the per org application config -type ApplicationOrgConfig interface { - OrgConfig - - // AnchorPeers returns the list of gossip anchor peers - AnchorPeers() []*pb.AnchorPeer -} - -// ApplicationConfig stores the common shared application config -type ApplicationConfig interface { - // Organizations returns a map of org ID to ApplicationOrgConfig - Organizations() map[string]ApplicationOrgConfig -} - -// OrdererConfig stores the common shared orderer config -type OrdererConfig interface { - // ConsensusType returns the configured consensus type - ConsensusType() string - - // BatchSize returns the maximum number of messages to include in a block - BatchSize() *ab.BatchSize - - // BatchTimeout returns the amount of time to wait before creating a batch - BatchTimeout() time.Duration - - // ChainCreationPolicyNames returns the policy names which are allowed for chain creation - // This field is only set for the system ordering chain - ChainCreationPolicyNames() []string - - // KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" - // Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers - // used for ordering - KafkaBrokers() []string - - // IngressPolicyNames returns the name of the policy to validate incoming broadcast messages against - IngressPolicyNames() []string - - // EgressPolicyNames returns the name of the policy to validate incoming broadcast messages against - EgressPolicyNames() []string -} - -// Handler provides a hook which allows other pieces of code to participate in config proposals -// TODO, this should probably be renamed to ValueHandler -type Handler interface { - Transactional - - // ProposeConfig called when config is added to a proposal - ProposeConfig(key string, configValue *cb.ConfigValue) error -} - // Manager provides a mechanism to query and update config type Manager interface { Resources @@ -126,13 +51,13 @@ type Resources interface { PolicyManager() policies.Manager // ChannelConfig returns the ChannelConfig for the chain - ChannelConfig() ChannelConfig + ChannelConfig() configvalues.Channel // OrdererConfig returns the configtxorderer.SharedConfig for the channel - OrdererConfig() OrdererConfig + OrdererConfig() configvalues.Orderer // ApplicationConfig returns the configtxapplication.SharedConfig for the channel - ApplicationConfig() ApplicationConfig + ApplicationConfig() configvalues.Application // MSPManager returns the msp.MSPManager for the chain MSPManager() msp.MSPManager @@ -140,27 +65,32 @@ type Resources interface { // Transactional is an interface which allows for an update to be proposed and rolled back type Transactional interface { - // BeginConfig called when a config proposal is begun - BeginConfig(groups []string) ([]Handler, error) - // RollbackConfig called when a config proposal is abandoned - RollbackConfig() + RollbackProposals() // CommitConfig called when a config proposal is committed - CommitConfig() + CommitProposals() } // PolicyHandler is used for config updates to policy type PolicyHandler interface { Transactional + BeginConfig(groups []string) ([]PolicyHandler, error) + ProposePolicy(key string, path []string, policy *cb.ConfigPolicy) error } // Initializer is used as indirection between Manager and Handler to allow // for single Handlers to handle multiple paths type Initializer interface { - Handler + // ProposeValue is used for propsing group values + ProposeValue(key string, configValue *cb.ConfigValue) error + + // BeginValueProposals is called when a config proposal is begun + BeginValueProposals(groups []string) ([]configvalues.ValueProposer, error) + + Transactional Resources diff --git a/common/configtx/config.go b/common/configtx/config.go index 230dbc6e70b..aeebb3a6cca 100644 --- a/common/configtx/config.go +++ b/common/configtx/config.go @@ -20,6 +20,7 @@ import ( "fmt" "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" cb "github.com/hyperledger/fabric/protos/common" ) @@ -32,21 +33,21 @@ func (cr *configResult) commit() { for _, subResult := range cr.subResults { subResult.commit() } - cr.handler.CommitConfig() + cr.handler.CommitProposals() } func (cr *configResult) rollback() { for _, subResult := range cr.subResults { subResult.rollback() } - cr.handler.RollbackConfig() + cr.handler.RollbackProposals() } // proposeGroup proposes a group configuration with a given handler // it will in turn recursively call itself until all groups have been exhausted // at each call, it returns the handler that was passed in, plus any handlers returned // by recursive calls into proposeGroup -func (cm *configManager) proposeGroup(name string, group *cb.ConfigGroup, handler api.Handler) (*configResult, error) { +func (cm *configManager) proposeGroup(name string, group *cb.ConfigGroup, handler configvaluesapi.ValueProposer) (*configResult, error) { subGroups := make([]string, len(group.Groups)) i := 0 for subGroup := range group.Groups { @@ -55,7 +56,7 @@ func (cm *configManager) proposeGroup(name string, group *cb.ConfigGroup, handle } logger.Debugf("Beginning new config for channel %s and group %s", cm.chainID, name) - subHandlers, err := handler.BeginConfig(subGroups) + subHandlers, err := handler.BeginValueProposals(subGroups) if err != nil { return nil, err } @@ -79,7 +80,7 @@ func (cm *configManager) proposeGroup(name string, group *cb.ConfigGroup, handle } for key, value := range group.Values { - if err := handler.ProposeConfig(key, value); err != nil { + if err := handler.ProposeValue(key, value); err != nil { result.rollback() return nil, err } @@ -94,7 +95,7 @@ func (cm *configManager) proposePolicies(rootGroup *cb.ConfigGroup) (*configResu for key, policy := range rootGroup.Policies { logger.Debugf("Proposing policy: %s", key) if err := cm.initializer.PolicyHandler().ProposePolicy(key, []string{RootGroupKey}, policy); err != nil { - cm.initializer.PolicyHandler().RollbackConfig() + cm.initializer.PolicyHandler().RollbackProposals() return nil, err } } diff --git a/common/configtx/initializer.go b/common/configtx/initializer.go index 0e6e7533d71..838b4651e04 100644 --- a/common/configtx/initializer.go +++ b/common/configtx/initializer.go @@ -21,10 +21,11 @@ import ( "github.com/hyperledger/fabric/common/cauthdsl" "github.com/hyperledger/fabric/common/configtx/api" - configtxapplication "github.com/hyperledger/fabric/common/configtx/handlers/application" - configtxchannel "github.com/hyperledger/fabric/common/configtx/handlers/channel" - configtxmsp "github.com/hyperledger/fabric/common/configtx/handlers/msp" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" + 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" + configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" @@ -44,17 +45,17 @@ func (r *resources) PolicyManager() policies.Manager { } // ChannelConfig returns the api.ChannelConfig for the chain -func (r *resources) ChannelConfig() api.ChannelConfig { +func (r *resources) ChannelConfig() configvaluesapi.Channel { return r.channelConfig } // OrdererConfig returns the api.OrdererConfig for the chain -func (r *resources) OrdererConfig() api.OrdererConfig { +func (r *resources) OrdererConfig() configvaluesapi.Orderer { return r.ordererConfig } // ApplicationConfig returns the api.ApplicationConfig for the chain -func (r *resources) ApplicationConfig() api.ApplicationConfig { +func (r *resources) ApplicationConfig() configvaluesapi.Application { return r.applicationConfig } @@ -104,35 +105,35 @@ func NewInitializer() api.Initializer { } } -// BeginConfig is used to start a new config proposal -func (i *initializer) BeginConfig(groups []string) ([]api.Handler, error) { +// BeginValueProposals is used to start a new config proposal +func (i *initializer) BeginValueProposals(groups []string) ([]configvaluesapi.ValueProposer, error) { if len(groups) != 1 { logger.Panicf("Initializer only supports having one root group") } i.mspConfigHandler.BeginConfig() - return []api.Handler{i.channelConfig}, nil + return []configvaluesapi.ValueProposer{i.channelConfig}, nil } // RollbackConfig is used to abandon a new config proposal -func (i *initializer) RollbackConfig() { - i.mspConfigHandler.RollbackConfig() +func (i *initializer) RollbackProposals() { + i.mspConfigHandler.RollbackProposals() } // CommitConfig is used to commit a new config proposal -func (i *initializer) CommitConfig() { - i.mspConfigHandler.CommitConfig() +func (i *initializer) CommitProposals() { + i.mspConfigHandler.CommitProposals() } type importHack struct { *policies.ManagerImpl } -func (ih importHack) BeginConfig(groups []string) ([]api.Handler, error) { +func (ih importHack) BeginConfig(groups []string) ([]api.PolicyHandler, error) { policyManagers, err := ih.ManagerImpl.BeginConfig(groups) if err != nil { return nil, err } - handlers := make([]api.Handler, len(policyManagers)) + handlers := make([]api.PolicyHandler, len(policyManagers)) for i, policyManager := range policyManagers { handlers[i] = &importHack{ManagerImpl: policyManager} } @@ -147,6 +148,6 @@ func (i *initializer) PolicyHandler() api.PolicyHandler { return importHack{ManagerImpl: i.policyManager} } -func (i *initializer) ProposeConfig(key string, value *cb.ConfigValue) error { +func (i *initializer) ProposeValue(key string, value *cb.ConfigValue) error { return fmt.Errorf("Programming error, this should never be invoked") } diff --git a/common/configtx/template.go b/common/configtx/template.go index 42b2d8568cf..021b1bdda39 100644 --- a/common/configtx/template.go +++ b/common/configtx/template.go @@ -17,7 +17,7 @@ limitations under the License. package configtx import ( - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" "github.com/hyperledger/fabric/common/util" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" diff --git a/common/configtx/template_test.go b/common/configtx/template_test.go index 9c3596027d2..111d6f3266b 100644 --- a/common/configtx/template_test.go +++ b/common/configtx/template_test.go @@ -21,7 +21,7 @@ import ( "testing" "github.com/golang/protobuf/proto" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" diff --git a/common/configtx/test/helper.go b/common/configtx/test/helper.go index 4889b484b75..480b07f3c74 100644 --- a/common/configtx/test/helper.go +++ b/common/configtx/test/helper.go @@ -21,11 +21,11 @@ import ( "path/filepath" "github.com/hyperledger/fabric/common/configtx" - configtxapplication "github.com/hyperledger/fabric/common/configtx/handlers/application" - configtxmsp "github.com/hyperledger/fabric/common/configtx/handlers/msp" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/common/configtx/tool/provisional" + configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" + configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp" "github.com/hyperledger/fabric/common/genesis" "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" diff --git a/common/configtx/tool/provisional/provisional.go b/common/configtx/tool/provisional/provisional.go index f2767bc2c5c..a2d2c17fbe6 100644 --- a/common/configtx/tool/provisional/provisional.go +++ b/common/configtx/tool/provisional/provisional.go @@ -21,9 +21,9 @@ import ( "github.com/hyperledger/fabric/common/cauthdsl" "github.com/hyperledger/fabric/common/configtx" - configtxchannel "github.com/hyperledger/fabric/common/configtx/handlers/channel" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" + configtxchannel "github.com/hyperledger/fabric/common/configvalues/channel" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" "github.com/hyperledger/fabric/common/genesis" "github.com/hyperledger/fabric/orderer/common/bootstrap" cb "github.com/hyperledger/fabric/protos/common" diff --git a/common/configvalues/api/api.go b/common/configvalues/api/api.go new file mode 100644 index 00000000000..b2bd60a8834 --- /dev/null +++ b/common/configvalues/api/api.go @@ -0,0 +1,103 @@ +/* +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 api + +import ( + "time" + + cb "github.com/hyperledger/fabric/protos/common" + ab "github.com/hyperledger/fabric/protos/orderer" + pb "github.com/hyperledger/fabric/protos/peer" +) + +// Channel stores the common channel config +type Channel interface { + // HashingAlgorithm returns the default algorithm to be used when hashing + // such as computing block hashes, and CreationPolicy digests + HashingAlgorithm() func(input []byte) []byte + + // BlockDataHashingStructureWidth returns the width to use when constructing the + // Merkle tree to compute the BlockData hash + BlockDataHashingStructureWidth() uint32 + + // OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver + OrdererAddresses() []string +} + +// Org stores the common organizational config +type Org interface { + // Name returns the name this org is referred to in config + Name() string + + // MSPID returns the MSP ID associated with this org + MSPID() string +} + +// ApplicationOrg stores the per org application config +type ApplicationOrg interface { + Org + + // AnchorPeers returns the list of gossip anchor peers + AnchorPeers() []*pb.AnchorPeer +} + +// Application stores the common shared application config +type Application interface { + // Organizations returns a map of org ID to ApplicationOrg + Organizations() map[string]ApplicationOrg +} + +// Orderer stores the common shared orderer config +type Orderer interface { + // ConsensusType returns the configured consensus type + ConsensusType() string + + // BatchSize returns the maximum number of messages to include in a block + BatchSize() *ab.BatchSize + + // BatchTimeout returns the amount of time to wait before creating a batch + BatchTimeout() time.Duration + + // ChainCreationPolicyNames returns the policy names which are allowed for chain creation + // This field is only set for the system ordering chain + ChainCreationPolicyNames() []string + + // KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" + // Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers + // used for ordering + KafkaBrokers() []string + + // IngressPolicyNames returns the name of the policy to validate incoming broadcast messages against + IngressPolicyNames() []string + + // EgressPolicyNames returns the name of the policy to validate incoming broadcast messages against + EgressPolicyNames() []string +} + +type ValueProposer interface { + // BeginValueProposals called when a config proposal is begun + BeginValueProposals(groups []string) ([]ValueProposer, error) + + // ProposeValue called when config is added to a proposal + ProposeValue(key string, configValue *cb.ConfigValue) error + + // RollbackProposals called when a config proposal is abandoned + RollbackProposals() + + // CommitProposals called when a config proposal is committed + CommitProposals() +} diff --git a/common/configtx/handlers/application/organization.go b/common/configvalues/channel/application/organization.go similarity index 73% rename from common/configtx/handlers/application/organization.go rename to common/configvalues/channel/application/organization.go index 2c066f012b8..91077fc6b96 100644 --- a/common/configtx/handlers/application/organization.go +++ b/common/configvalues/channel/application/organization.go @@ -19,9 +19,9 @@ package application import ( "fmt" - "github.com/hyperledger/fabric/common/configtx/api" - "github.com/hyperledger/fabric/common/configtx/handlers" - mspconfig "github.com/hyperledger/fabric/common/configtx/handlers/msp" + "github.com/hyperledger/fabric/common/configvalues/api" + "github.com/hyperledger/fabric/common/configvalues/channel/common/organization" + mspconfig "github.com/hyperledger/fabric/common/configvalues/msp" cb "github.com/hyperledger/fabric/protos/common" pb "github.com/hyperledger/fabric/protos/peer" @@ -42,7 +42,7 @@ type applicationOrgConfig struct { // SharedConfigImpl is an implementation of Manager and configtx.ConfigHandler // In general, it should only be referenced as an Impl for the configtx.Manager type ApplicationOrgConfig struct { - *handlers.OrgConfig + *organization.OrgConfig pendingConfig *applicationOrgConfig config *applicationOrgConfig @@ -52,7 +52,7 @@ type ApplicationOrgConfig struct { // NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper func NewApplicationOrgConfig(id string, mspConfig *mspconfig.MSPConfigHandler) *ApplicationOrgConfig { return &ApplicationOrgConfig{ - OrgConfig: handlers.NewOrgConfig(id, mspConfig), + OrgConfig: organization.NewOrgConfig(id, mspConfig), config: &applicationOrgConfig{}, } } @@ -62,8 +62,8 @@ func (oc *ApplicationOrgConfig) AnchorPeers() []*pb.AnchorPeer { return oc.config.anchorPeers } -// BeginConfig is used to start a new config proposal -func (oc *ApplicationOrgConfig) BeginConfig(groups []string) ([]api.Handler, error) { +// BeginValueProposals is used to start a new config proposal +func (oc *ApplicationOrgConfig) BeginValueProposals(groups []string) ([]api.ValueProposer, error) { logger.Debugf("Beginning a possible new org config") if len(groups) != 0 { return nil, fmt.Errorf("ApplicationGroup does not support subgroups") @@ -72,29 +72,29 @@ func (oc *ApplicationOrgConfig) BeginConfig(groups []string) ([]api.Handler, err logger.Panicf("Programming error, cannot call begin in the middle of a proposal") } oc.pendingConfig = &applicationOrgConfig{} - return oc.OrgConfig.BeginConfig(groups) + return oc.OrgConfig.BeginValueProposals(groups) } -// RollbackConfig is used to abandon a new config proposal -func (oc *ApplicationOrgConfig) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (oc *ApplicationOrgConfig) RollbackProposals() { logger.Debugf("Rolling back proposed org config") oc.pendingConfig = nil - oc.OrgConfig.RollbackConfig() + oc.OrgConfig.RollbackProposals() } -// CommitConfig is used to commit a new config proposal -func (oc *ApplicationOrgConfig) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (oc *ApplicationOrgConfig) CommitProposals() { logger.Debugf("Committing new org config") if oc.pendingConfig == nil { logger.Panicf("Programming error, cannot call commit without an existing proposal") } oc.config = oc.pendingConfig oc.pendingConfig = nil - oc.OrgConfig.CommitConfig() + oc.OrgConfig.CommitProposals() } -// ProposeConfig is used to add new config to the config proposal -func (oc *ApplicationOrgConfig) ProposeConfig(key string, configValue *cb.ConfigValue) error { +// ProposeValue is used to add new config to the config proposal +func (oc *ApplicationOrgConfig) ProposeValue(key string, configValue *cb.ConfigValue) error { switch key { case AnchorPeersKey: anchorPeers := &pb.AnchorPeers{} @@ -106,7 +106,7 @@ func (oc *ApplicationOrgConfig) ProposeConfig(key string, configValue *cb.Config } oc.pendingConfig.anchorPeers = anchorPeers.AnchorPeers default: - return oc.OrgConfig.ProposeConfig(key, configValue) + return oc.OrgConfig.ProposeValue(key, configValue) } return nil diff --git a/common/configtx/handlers/application/organization_test.go b/common/configvalues/channel/application/organization_test.go similarity index 76% rename from common/configtx/handlers/application/organization_test.go rename to common/configvalues/channel/application/organization_test.go index 9406004e7e4..ba860ce84e4 100644 --- a/common/configtx/handlers/application/organization_test.go +++ b/common/configvalues/channel/application/organization_test.go @@ -19,7 +19,7 @@ package application import ( "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + "github.com/hyperledger/fabric/common/configvalues/api" cb "github.com/hyperledger/fabric/protos/common" pb "github.com/hyperledger/fabric/protos/peer" @@ -47,24 +47,24 @@ func groupToKeyValue(configGroup *cb.ConfigGroup) (string, *cb.ConfigValue) { } func TestApplicationOrgInterface(t *testing.T) { - _ = configtxapi.Handler(NewApplicationOrgConfig("id", nil)) + _ = api.ValueProposer(NewApplicationOrgConfig("id", nil)) } func TestApplicationOrgDoubleBegin(t *testing.T) { m := NewApplicationOrgConfig("id", nil) - m.BeginConfig(nil) - assert.Panics(t, func() { m.BeginConfig(nil) }, "Two begins back to back should have caused a panic") + m.BeginValueProposals(nil) + assert.Panics(t, func() { m.BeginValueProposals(nil) }, "Two begins back to back should have caused a panic") } func TestApplicationOrgCommitWithoutBegin(t *testing.T) { m := NewApplicationOrgConfig("id", nil) - assert.Panics(t, m.CommitConfig, "Committing without beginning should have caused a panic") + assert.Panics(t, m.CommitProposals, "Committing without beginning should have caused a panic") } func TestApplicationOrgRollback(t *testing.T) { m := NewApplicationOrgConfig("id", nil) m.pendingConfig = &applicationOrgConfig{} - m.RollbackConfig() + m.RollbackProposals() assert.Nil(t, m.pendingConfig, "Should have cleared pending config on rollback") } @@ -76,11 +76,11 @@ func TestApplicationOrgAnchorPeers(t *testing.T) { invalidMessage := makeInvalidConfigValue() validMessage := TemplateAnchorPeers("id", endVal) m := NewApplicationOrgConfig("id", nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - assert.Error(t, m.ProposeConfig(AnchorPeersKey, invalidMessage), "Should have failed on invalid message") - assert.NoError(t, m.ProposeConfig(groupToKeyValue(validMessage)), "Should not have failed on invalid message") - m.CommitConfig() + assert.Error(t, m.ProposeValue(AnchorPeersKey, invalidMessage), "Should have failed on invalid message") + assert.NoError(t, m.ProposeValue(groupToKeyValue(validMessage)), "Should not have failed on invalid message") + m.CommitProposals() assert.Equal(t, m.AnchorPeers(), endVal, "Did not set updated anchor peers") } diff --git a/common/configtx/handlers/application/sharedconfig.go b/common/configvalues/channel/application/sharedconfig.go similarity index 73% rename from common/configtx/handlers/application/sharedconfig.go rename to common/configvalues/channel/application/sharedconfig.go index 095163d0d93..b9ba38c3668 100644 --- a/common/configtx/handlers/application/sharedconfig.go +++ b/common/configvalues/channel/application/sharedconfig.go @@ -17,9 +17,9 @@ limitations under the License. package application import ( - "github.com/hyperledger/fabric/common/configtx/api" - "github.com/hyperledger/fabric/common/configtx/handlers" - "github.com/hyperledger/fabric/common/configtx/handlers/msp" + "github.com/hyperledger/fabric/common/configvalues/api" + "github.com/hyperledger/fabric/common/configvalues/channel/common/organization" + "github.com/hyperledger/fabric/common/configvalues/msp" cb "github.com/hyperledger/fabric/protos/common" "github.com/op/go-logging" @@ -33,8 +33,8 @@ const ( var orgSchema = &cb.ConfigGroupSchema{ Groups: map[string]*cb.ConfigGroupSchema{}, Values: map[string]*cb.ConfigValueSchema{ - AnchorPeersKey: nil, - handlers.MSPKey: nil, // TODO, consolidate into a constant once common org code exists + AnchorPeersKey: nil, + organization.MSPKey: nil, // TODO, consolidate into a constant once common org code exists }, Policies: map[string]*cb.ConfigPolicySchema{ // TODO, set appropriately once hierarchical policies are implemented @@ -54,7 +54,7 @@ var Schema = &cb.ConfigGroupSchema{ var logger = logging.MustGetLogger("common/configtx/handlers/application") type sharedConfig struct { - orgs map[string]api.ApplicationOrgConfig + orgs map[string]api.ApplicationOrg } // SharedConfigImpl is an implementation of Manager and configtx.ConfigHandler @@ -74,16 +74,16 @@ func NewSharedConfigImpl(mspConfig *msp.MSPConfigHandler) *SharedConfigImpl { } } -// BeginConfig is used to start a new config proposal -func (di *SharedConfigImpl) BeginConfig(groups []string) ([]api.Handler, error) { +// BeginValueProposals is used to start a new config proposal +func (di *SharedConfigImpl) BeginValueProposals(groups []string) ([]api.ValueProposer, error) { logger.Debugf("Beginning a possible new peer shared config") if di.pendingConfig != nil { logger.Panicf("Programming error, cannot call begin in the middle of a proposal") } di.pendingConfig = &sharedConfig{ - orgs: make(map[string]api.ApplicationOrgConfig), + orgs: make(map[string]api.ApplicationOrg), } - orgHandlers := make([]api.Handler, len(groups)) + orgHandlers := make([]api.ValueProposer, len(groups)) for i, group := range groups { org, ok := di.pendingConfig.orgs[group] if !ok { @@ -95,14 +95,14 @@ func (di *SharedConfigImpl) BeginConfig(groups []string) ([]api.Handler, error) return orgHandlers, nil } -// RollbackConfig is used to abandon a new config proposal -func (di *SharedConfigImpl) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (di *SharedConfigImpl) RollbackProposals() { logger.Debugf("Rolling back proposed peer shared config") di.pendingConfig = nil } -// CommitConfig is used to commit a new config proposal -func (di *SharedConfigImpl) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (di *SharedConfigImpl) CommitProposals() { logger.Debugf("Committing new peer shared config") if di.pendingConfig == nil { logger.Panicf("Programming error, cannot call commit without an existing proposal") @@ -111,13 +111,13 @@ func (di *SharedConfigImpl) CommitConfig() { di.pendingConfig = nil } -// ProposeConfig is used to add new config to the config proposal -func (di *SharedConfigImpl) ProposeConfig(key string, configValue *cb.ConfigValue) error { +// ProposeValue is used to add new config to the config proposal +func (di *SharedConfigImpl) ProposeValue(key string, configValue *cb.ConfigValue) error { logger.Warningf("Uknown Peer config item with key %s", key) return nil } -// Organizations returns a map of org ID to ApplicationOrgConfig -func (di *SharedConfigImpl) Organizations() map[string]api.ApplicationOrgConfig { +// Organizations returns a map of org ID to ApplicationOrg +func (di *SharedConfigImpl) Organizations() map[string]api.ApplicationOrg { return di.config.orgs } diff --git a/common/configtx/handlers/application/sharedconfig_test.go b/common/configvalues/channel/application/sharedconfig_test.go similarity index 87% rename from common/configtx/handlers/application/sharedconfig_test.go rename to common/configvalues/channel/application/sharedconfig_test.go index 50239ed75f5..2f3fa20e75a 100644 --- a/common/configtx/handlers/application/sharedconfig_test.go +++ b/common/configvalues/channel/application/sharedconfig_test.go @@ -19,7 +19,7 @@ package application import ( "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + "github.com/hyperledger/fabric/common/configvalues/api" logging "github.com/op/go-logging" ) @@ -29,7 +29,7 @@ func init() { } func TestApplicationInterface(t *testing.T) { - _ = configtxapi.ApplicationConfig(NewSharedConfigImpl(nil)) + _ = api.Application(NewSharedConfigImpl(nil)) } func TestApplicationDoubleBegin(t *testing.T) { @@ -40,8 +40,8 @@ func TestApplicationDoubleBegin(t *testing.T) { }() m := NewSharedConfigImpl(nil) - m.BeginConfig(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) + m.BeginValueProposals(nil) } func TestApplicationCommitWithoutBegin(t *testing.T) { @@ -52,13 +52,13 @@ func TestApplicationCommitWithoutBegin(t *testing.T) { }() m := NewSharedConfigImpl(nil) - m.CommitConfig() + m.CommitProposals() } func TestApplicationRollback(t *testing.T) { m := NewSharedConfigImpl(nil) m.pendingConfig = &sharedConfig{} - m.RollbackConfig() + m.RollbackProposals() if m.pendingConfig != nil { t.Fatalf("Should have cleared pending config on rollback") } diff --git a/common/configtx/handlers/application/sharedconfig_util.go b/common/configvalues/channel/application/sharedconfig_util.go similarity index 100% rename from common/configtx/handlers/application/sharedconfig_util.go rename to common/configvalues/channel/application/sharedconfig_util.go diff --git a/common/configtx/handlers/organization.go b/common/configvalues/channel/common/organization/organization.go similarity index 84% rename from common/configtx/handlers/organization.go rename to common/configvalues/channel/common/organization/organization.go index deca64d40ee..9a01b41bbbe 100644 --- a/common/configtx/handlers/organization.go +++ b/common/configvalues/channel/common/organization/organization.go @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package handlers +package organization import ( "fmt" - "github.com/hyperledger/fabric/common/configtx/api" - mspconfig "github.com/hyperledger/fabric/common/configtx/handlers/msp" + "github.com/hyperledger/fabric/common/configvalues/api" + mspconfig "github.com/hyperledger/fabric/common/configvalues/msp" "github.com/hyperledger/fabric/msp" cb "github.com/hyperledger/fabric/protos/common" mspprotos "github.com/hyperledger/fabric/protos/msp" @@ -61,8 +61,8 @@ func NewOrgConfig(id string, mspConfig *mspconfig.MSPConfigHandler) *OrgConfig { } } -// BeginConfig is used to start a new config proposal -func (oc *OrgConfig) BeginConfig(groups []string) ([]api.Handler, error) { +// BeginValueProposals is used to start a new config proposal +func (oc *OrgConfig) BeginValueProposals(groups []string) ([]api.ValueProposer, error) { logger.Debugf("Beginning a possible new org config") if len(groups) != 0 { return nil, fmt.Errorf("Orgs do not support sub-groups") @@ -75,14 +75,14 @@ func (oc *OrgConfig) BeginConfig(groups []string) ([]api.Handler, error) { return nil, nil } -// RollbackConfig is used to abandon a new config proposal -func (oc *OrgConfig) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (oc *OrgConfig) RollbackProposals() { logger.Debugf("Rolling back proposed org config") oc.pendingConfig = nil } -// CommitConfig is used to commit a new config proposal -func (oc *OrgConfig) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (oc *OrgConfig) CommitProposals() { logger.Debugf("Committing new org config") if oc.pendingConfig == nil { logger.Panicf("Programming error, cannot call commit without an existing proposal") @@ -101,8 +101,8 @@ func (oc *OrgConfig) MSPID() string { return oc.mspID } -// ProposeConfig is used to add new config to the config proposal -func (oc *OrgConfig) ProposeConfig(key string, configValue *cb.ConfigValue) error { +// ProposeValue is used to add new config to the config proposal +func (oc *OrgConfig) ProposeValue(key string, configValue *cb.ConfigValue) error { switch key { case MSPKey: logger.Debugf("Initializing org MSP for id %s", oc.id) diff --git a/common/configtx/handlers/organization_test.go b/common/configvalues/channel/common/organization/organization_test.go similarity index 85% rename from common/configtx/handlers/organization_test.go rename to common/configvalues/channel/common/organization/organization_test.go index b204ab5f553..7f607c7269c 100644 --- a/common/configtx/handlers/organization_test.go +++ b/common/configvalues/channel/common/organization/organization_test.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package handlers +package organization import ( "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + "github.com/hyperledger/fabric/common/configvalues/api" logging "github.com/op/go-logging" ) @@ -29,7 +29,7 @@ func init() { } func TestInterface(t *testing.T) { - _ = configtxapi.Handler(NewOrgConfig("id", nil)) + _ = api.ValueProposer(NewOrgConfig("id", nil)) } func TestDoubleBegin(t *testing.T) { @@ -40,8 +40,8 @@ func TestDoubleBegin(t *testing.T) { }() m := NewOrgConfig("id", nil) - m.BeginConfig(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) + m.BeginValueProposals(nil) } func TestCommitWithoutBegin(t *testing.T) { @@ -52,13 +52,13 @@ func TestCommitWithoutBegin(t *testing.T) { }() m := NewOrgConfig("id", nil) - m.CommitConfig() + m.CommitProposals() } func TestRollback(t *testing.T) { m := NewOrgConfig("id", nil) m.pendingConfig = &orgConfig{} - m.RollbackConfig() + m.RollbackProposals() if m.pendingConfig != nil { t.Fatalf("Should have cleared pending config on rollback") } diff --git a/common/configtx/handlers/orderer/sharedconfig.go b/common/configvalues/channel/orderer/sharedconfig.go similarity index 91% rename from common/configtx/handlers/orderer/sharedconfig.go rename to common/configvalues/channel/orderer/sharedconfig.go index 8e66cbe3776..2e6061860cc 100644 --- a/common/configtx/handlers/orderer/sharedconfig.go +++ b/common/configvalues/channel/orderer/sharedconfig.go @@ -23,9 +23,9 @@ import ( "strings" "time" - "github.com/hyperledger/fabric/common/configtx/api" - "github.com/hyperledger/fabric/common/configtx/handlers" - "github.com/hyperledger/fabric/common/configtx/handlers/msp" + "github.com/hyperledger/fabric/common/configvalues/api" + "github.com/hyperledger/fabric/common/configvalues/channel/common/organization" + "github.com/hyperledger/fabric/common/configvalues/msp" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" @@ -99,10 +99,10 @@ type ordererConfig struct { kafkaBrokers []string ingressPolicyNames []string egressPolicyNames []string - orgs map[string]*handlers.OrgConfig + orgs map[string]*organization.OrgConfig } -// ManagerImpl is an implementation of configtxapi.OrdererConfig and configtxapi.Handler +// ManagerImpl is an implementation of configtxapi.OrdererConfig and configtxapi.ValueProposer type ManagerImpl struct { pendingConfig *ordererConfig config *ordererConfig @@ -156,20 +156,20 @@ func (pm *ManagerImpl) EgressPolicyNames() []string { return pm.config.egressPolicyNames } -// BeginConfig is used to start a new config proposal -func (pm *ManagerImpl) BeginConfig(groups []string) ([]api.Handler, error) { +// BeginValueProposals is used to start a new config proposal +func (pm *ManagerImpl) BeginValueProposals(groups []string) ([]api.ValueProposer, error) { logger.Debugf("Beginning a possible new orderer shared config") if pm.pendingConfig != nil { logger.Panicf("Programming error, cannot call begin in the middle of a proposal") } pm.pendingConfig = &ordererConfig{ - orgs: make(map[string]*handlers.OrgConfig), + orgs: make(map[string]*organization.OrgConfig), } - orgHandlers := make([]api.Handler, len(groups)) + orgHandlers := make([]api.ValueProposer, len(groups)) for i, group := range groups { org, ok := pm.pendingConfig.orgs[group] if !ok { - org = handlers.NewOrgConfig(group, pm.mspConfig) + org = organization.NewOrgConfig(group, pm.mspConfig) pm.pendingConfig.orgs[group] = org } orgHandlers[i] = org @@ -177,14 +177,14 @@ func (pm *ManagerImpl) BeginConfig(groups []string) ([]api.Handler, error) { return orgHandlers, nil } -// RollbackConfig is used to abandon a new config proposal -func (pm *ManagerImpl) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (pm *ManagerImpl) RollbackProposals() { logger.Debugf("Rolling back orderer config") pm.pendingConfig = nil } -// CommitConfig is used to commit a new config proposal -func (pm *ManagerImpl) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (pm *ManagerImpl) CommitProposals() { if pm.pendingConfig == nil { logger.Fatalf("Programming error, cannot call commit without an existing proposal") } @@ -195,8 +195,8 @@ func (pm *ManagerImpl) CommitConfig() { } } -// ProposeConfig is used to add new config to the config proposal -func (pm *ManagerImpl) ProposeConfig(key string, configValue *cb.ConfigValue) error { +// ProposeValue is used to add new config to the config proposal +func (pm *ManagerImpl) ProposeValue(key string, configValue *cb.ConfigValue) error { switch key { case ConsensusTypeKey: consensusType := &ab.ConsensusType{} diff --git a/common/configtx/handlers/orderer/sharedconfig_test.go b/common/configvalues/channel/orderer/sharedconfig_test.go similarity index 78% rename from common/configtx/handlers/orderer/sharedconfig_test.go rename to common/configvalues/channel/orderer/sharedconfig_test.go index 7e7d50e777b..b14ed64c106 100644 --- a/common/configtx/handlers/orderer/sharedconfig_test.go +++ b/common/configvalues/channel/orderer/sharedconfig_test.go @@ -66,8 +66,8 @@ func doesFuncCrash(crasher func(), test string) bool { func TestDoubleBegin(t *testing.T) { crashes := doesFuncCrash(func() { m := NewManagerImpl(nil) - m.BeginConfig(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) + m.BeginValueProposals(nil) }, "TestDoubleBegin") if !crashes { @@ -78,7 +78,7 @@ func TestDoubleBegin(t *testing.T) { func TestCommitWithoutBegin(t *testing.T) { crashes := doesFuncCrash(func() { m := NewManagerImpl(nil) - m.CommitConfig() + m.CommitProposals() }, "TestCommitWithoutBegin") if !crashes { @@ -89,7 +89,7 @@ func TestCommitWithoutBegin(t *testing.T) { func TestRollback(t *testing.T) { m := NewManagerImpl(nil) m.pendingConfig = &ordererConfig{} - m.RollbackConfig() + m.RollbackProposals() if m.pendingConfig != nil { t.Fatalf("Should have cleared pending config on rollback") } @@ -102,32 +102,32 @@ func TestConsensusType(t *testing.T) { otherValidMessage := TemplateConsensusType("bar") m := NewManagerImpl(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(groupToKeyValue(validMessage)) + err := m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() - m.BeginConfig(nil) + m.CommitProposals() + m.BeginValueProposals(nil) - err = m.ProposeConfig(ConsensusTypeKey, invalidMessage) + err = m.ProposeValue(ConsensusTypeKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(validMessage)) + err = m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error re-applying valid config: %s", err) } - err = m.ProposeConfig(groupToKeyValue(otherValidMessage)) + err = m.ProposeValue(groupToKeyValue(otherValidMessage)) if err == nil { t.Fatalf("Should not have applied config with different consensus type after it was initially set") } - m.CommitConfig() + m.CommitProposals() if nowType := m.ConsensusType(); nowType != endType { t.Fatalf("Consensus type should have ended as %s but was %s", endType, nowType) @@ -142,12 +142,12 @@ func TestBatchSize(t *testing.T) { t.Run("ValidConfig", func(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) - err := m.ProposeConfig( + m.BeginValueProposals(nil) + err := m.ProposeValue( groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: validMaxMessageCount, AbsoluteMaxBytes: validAbsoluteMaxBytes, PreferredMaxBytes: validPreferredMaxBytes})), ) assert.Nil(t, err, "Error applying valid config: %s", err) - m.CommitConfig() + m.CommitProposals() if m.BatchSize().MaxMessageCount != validMaxMessageCount { t.Fatalf("Got batch size max message count of %d. Expected: %d", m.BatchSize().MaxMessageCount, validMaxMessageCount) } @@ -161,34 +161,34 @@ func TestBatchSize(t *testing.T) { t.Run("UnserializableConfig", func(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) - err := m.ProposeConfig(BatchSizeKey, invalidMessage()) + m.BeginValueProposals(nil) + err := m.ProposeValue(BatchSizeKey, invalidMessage()) assert.NotNil(t, err, "Should have failed on invalid message") - m.CommitConfig() + m.CommitProposals() }) t.Run("ZeroMaxMessageCount", func(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) - err := m.ProposeConfig(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: 0, AbsoluteMaxBytes: validAbsoluteMaxBytes, PreferredMaxBytes: validPreferredMaxBytes}))) + m.BeginValueProposals(nil) + err := m.ProposeValue(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: 0, AbsoluteMaxBytes: validAbsoluteMaxBytes, PreferredMaxBytes: validPreferredMaxBytes}))) assert.NotNil(t, err, "Should have rejected batch size max message count of 0") - m.CommitConfig() + m.CommitProposals() }) t.Run("ZeroAbsoluteMaxBytes", func(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) - err := m.ProposeConfig(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: validMaxMessageCount, AbsoluteMaxBytes: 0, PreferredMaxBytes: validPreferredMaxBytes}))) + m.BeginValueProposals(nil) + err := m.ProposeValue(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: validMaxMessageCount, AbsoluteMaxBytes: 0, PreferredMaxBytes: validPreferredMaxBytes}))) assert.NotNil(t, err, "Should have rejected batch size absolute max message bytes of 0") - m.CommitConfig() + m.CommitProposals() }) t.Run("TooLargePreferredMaxBytes", func(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) - err := m.ProposeConfig(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: validMaxMessageCount, AbsoluteMaxBytes: validAbsoluteMaxBytes, PreferredMaxBytes: validAbsoluteMaxBytes + 1}))) + m.BeginValueProposals(nil) + err := m.ProposeValue(groupToKeyValue(TemplateBatchSize(&ab.BatchSize{MaxMessageCount: validMaxMessageCount, AbsoluteMaxBytes: validAbsoluteMaxBytes, PreferredMaxBytes: validAbsoluteMaxBytes + 1}))) assert.NotNil(t, err, "Should have rejected batch size preferred max message bytes greater than absolute max message bytes") - m.CommitConfig() + m.CommitProposals() }) } @@ -200,29 +200,29 @@ func TestBatchTimeout(t *testing.T) { validMessage := TemplateBatchTimeout(endBatchTimeout.String()) m := NewManagerImpl(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(groupToKeyValue(validMessage)) + err := m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - err = m.ProposeConfig(BatchTimeoutKey, invalidMessage) + err = m.ProposeValue(BatchTimeoutKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(negativeBatchTimeout)) + err = m.ProposeValue(groupToKeyValue(negativeBatchTimeout)) if err == nil { t.Fatalf("Should have rejected negative batch timeout: %s", err) } - err = m.ProposeConfig(groupToKeyValue(zeroBatchTimeout)) + err = m.ProposeValue(groupToKeyValue(zeroBatchTimeout)) if err == nil { t.Fatalf("Should have rejected batch timeout of 0") } - m.CommitConfig() + m.CommitProposals() if nowBatchTimeout := m.BatchTimeout(); nowBatchTimeout != endBatchTimeout { t.Fatalf("Got batch timeout of %s when expecting batch size of %s", nowBatchTimeout.String(), endBatchTimeout.String()) @@ -243,31 +243,31 @@ func TestKafkaBrokers(t *testing.T) { validMessage := TemplateKafkaBrokers(endList) m := NewManagerImpl(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(groupToKeyValue(validMessage)) + err := m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - err = m.ProposeConfig(KafkaBrokersKey, invalidMessage) + err = m.ProposeValue(KafkaBrokersKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(zeroBrokers)) + err = m.ProposeValue(groupToKeyValue(zeroBrokers)) if err == nil { t.Fatalf("Should have rejected empty brokers list") } for i := range badMessages { - err = m.ProposeConfig(groupToKeyValue(badMessages[i])) + err = m.ProposeValue(groupToKeyValue(badMessages[i])) if err == nil { t.Fatalf("Should have rejected broker address which is obviously malformed") } } - m.CommitConfig() + m.CommitProposals() nowList := m.KafkaBrokers() switch { @@ -283,27 +283,27 @@ func testPolicyNames(m *ManagerImpl, key string, initializer func(val []string) invalidMessage := invalidMessage() validMessage := initializer(endPolicy) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(groupToKeyValue(validMessage)) + err := m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() - m.BeginConfig(nil) + m.CommitProposals() + m.BeginValueProposals(nil) - err = m.ProposeConfig(key, invalidMessage) + err = m.ProposeValue(key, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(validMessage)) + err = m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error re-applying valid config: %s", err) } - m.CommitConfig() + m.CommitProposals() if nowPolicy := retriever(); !reflect.DeepEqual(nowPolicy, endPolicy) { t.Fatalf("%s should have ended as %s but was %s", key, endPolicy, nowPolicy) @@ -328,14 +328,14 @@ func TestChainCreationPolicyNames(t *testing.T) { func TestEmptyChainCreationPolicyNames(t *testing.T) { m := NewManagerImpl(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(groupToKeyValue(TemplateChainCreationPolicyNames(nil))) + err := m.ProposeValue(groupToKeyValue(TemplateChainCreationPolicyNames(nil))) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() + m.CommitProposals() if m.ChainCreationPolicyNames() == nil { t.Fatalf("Should have gotten back empty slice, not nil") diff --git a/common/configtx/handlers/orderer/sharedconfig_util.go b/common/configvalues/channel/orderer/sharedconfig_util.go similarity index 100% rename from common/configtx/handlers/orderer/sharedconfig_util.go rename to common/configvalues/channel/orderer/sharedconfig_util.go diff --git a/common/configtx/handlers/channel/sharedconfig.go b/common/configvalues/channel/sharedconfig.go similarity index 87% rename from common/configtx/handlers/channel/sharedconfig.go rename to common/configvalues/channel/sharedconfig.go index 69bfdd2eded..dac5303b430 100644 --- a/common/configtx/handlers/channel/sharedconfig.go +++ b/common/configvalues/channel/sharedconfig.go @@ -20,9 +20,9 @@ import ( "fmt" "math" - "github.com/hyperledger/fabric/common/configtx/api" - "github.com/hyperledger/fabric/common/configtx/handlers/application" - "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + "github.com/hyperledger/fabric/common/configvalues/api" + "github.com/hyperledger/fabric/common/configvalues/channel/application" + "github.com/hyperledger/fabric/common/configvalues/channel/orderer" "github.com/hyperledger/fabric/common/util" cb "github.com/hyperledger/fabric/protos/common" @@ -105,9 +105,9 @@ func (pm *SharedConfigImpl) OrdererAddresses() []string { return pm.config.ordererAddresses } -// BeginConfig is used to start a new config proposal -func (pm *SharedConfigImpl) BeginConfig(groups []string) ([]api.Handler, error) { - handlers := make([]api.Handler, len(groups)) +// BeginValueProposals is used to start a new config proposal +func (pm *SharedConfigImpl) BeginValueProposals(groups []string) ([]api.ValueProposer, error) { + handlers := make([]api.ValueProposer, len(groups)) for i, group := range groups { switch group { @@ -128,13 +128,13 @@ func (pm *SharedConfigImpl) BeginConfig(groups []string) ([]api.Handler, error) return handlers, nil } -// RollbackConfig is used to abandon a new config proposal -func (pm *SharedConfigImpl) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (pm *SharedConfigImpl) RollbackProposals() { pm.pendingConfig = nil } -// CommitConfig is used to commit a new config proposal -func (pm *SharedConfigImpl) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (pm *SharedConfigImpl) CommitProposals() { if pm.pendingConfig == nil { logger.Panicf("Programming error, cannot call commit without an existing proposal") } @@ -142,8 +142,8 @@ func (pm *SharedConfigImpl) CommitConfig() { pm.pendingConfig = nil } -// ProposeConfig is used to add new config to the config proposal -func (pm *SharedConfigImpl) ProposeConfig(key string, configValue *cb.ConfigValue) error { +// ProposeValue is used to add new config to the config proposal +func (pm *SharedConfigImpl) ProposeValue(key string, configValue *cb.ConfigValue) error { switch key { case HashingAlgorithmKey: hashingAlgorithm := &cb.HashingAlgorithm{} diff --git a/common/configtx/handlers/channel/sharedconfig_test.go b/common/configvalues/channel/sharedconfig_test.go similarity index 80% rename from common/configtx/handlers/channel/sharedconfig_test.go rename to common/configvalues/channel/sharedconfig_test.go index 691d28bc543..de817e66a74 100644 --- a/common/configtx/handlers/channel/sharedconfig_test.go +++ b/common/configvalues/channel/sharedconfig_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + "github.com/hyperledger/fabric/common/configvalues/api" cb "github.com/hyperledger/fabric/protos/common" logging "github.com/op/go-logging" @@ -44,7 +44,7 @@ func makeInvalidConfigValue() *cb.ConfigValue { } func TestInterface(t *testing.T) { - _ = configtxapi.ChannelConfig(NewSharedConfigImpl(nil, nil)) + _ = api.Channel(NewSharedConfigImpl(nil, nil)) } func TestDoubleBegin(t *testing.T) { @@ -55,8 +55,8 @@ func TestDoubleBegin(t *testing.T) { }() m := NewSharedConfigImpl(nil, nil) - m.BeginConfig(nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) + m.BeginValueProposals(nil) } func TestCommitWithoutBegin(t *testing.T) { @@ -67,13 +67,13 @@ func TestCommitWithoutBegin(t *testing.T) { }() m := NewSharedConfigImpl(nil, nil) - m.CommitConfig() + m.CommitProposals() } func TestRollback(t *testing.T) { m := NewSharedConfigImpl(nil, nil) m.pendingConfig = &chainConfig{} - m.RollbackConfig() + m.RollbackProposals() if m.pendingConfig != nil { t.Fatalf("Should have cleared pending config on rollback") } @@ -85,24 +85,24 @@ func TestHashingAlgorithm(t *testing.T) { validAlgorithm := DefaultHashingAlgorithm() m := NewSharedConfigImpl(nil, nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(HashingAlgorithmKey, invalidMessage) + err := m.ProposeValue(HashingAlgorithmKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(invalidAlgorithm)) + err = m.ProposeValue(groupToKeyValue(invalidAlgorithm)) if err == nil { t.Fatalf("Should have failed on invalid algorithm") } - err = m.ProposeConfig(groupToKeyValue(validAlgorithm)) + err = m.ProposeValue(groupToKeyValue(validAlgorithm)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() + m.CommitProposals() if m.HashingAlgorithm() == nil { t.Fatalf("Should have set default hashing algorithm") @@ -115,24 +115,24 @@ func TestBlockDataHashingStructure(t *testing.T) { validWidth := DefaultBlockDataHashingStructure() m := NewSharedConfigImpl(nil, nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(BlockDataHashingStructureKey, invalidMessage) + err := m.ProposeValue(BlockDataHashingStructureKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(invalidWidth)) + err = m.ProposeValue(groupToKeyValue(invalidWidth)) if err == nil { t.Fatalf("Should have failed on invalid width") } - err = m.ProposeConfig(groupToKeyValue(validWidth)) + err = m.ProposeValue(groupToKeyValue(validWidth)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() + m.CommitProposals() if newWidth := m.BlockDataHashingStructureWidth(); newWidth != defaultBlockDataHashingStructureWidth { t.Fatalf("Unexpected width, got %d expected %d", newWidth, defaultBlockDataHashingStructureWidth) @@ -143,19 +143,19 @@ func TestOrdererAddresses(t *testing.T) { invalidMessage := makeInvalidConfigValue() validMessage := DefaultOrdererAddresses() m := NewSharedConfigImpl(nil, nil) - m.BeginConfig(nil) + m.BeginValueProposals(nil) - err := m.ProposeConfig(OrdererAddressesKey, invalidMessage) + err := m.ProposeValue(OrdererAddressesKey, invalidMessage) if err == nil { t.Fatalf("Should have failed on invalid message") } - err = m.ProposeConfig(groupToKeyValue(validMessage)) + err = m.ProposeValue(groupToKeyValue(validMessage)) if err != nil { t.Fatalf("Error applying valid config: %s", err) } - m.CommitConfig() + m.CommitProposals() if newAddrs := m.OrdererAddresses(); !reflect.DeepEqual(newAddrs, defaultOrdererAddresses) { t.Fatalf("Unexpected width, got %s expected %s", newAddrs, defaultOrdererAddresses) diff --git a/common/configtx/handlers/channel/sharedconfig_util.go b/common/configvalues/channel/sharedconfig_util.go similarity index 100% rename from common/configtx/handlers/channel/sharedconfig_util.go rename to common/configvalues/channel/sharedconfig_util.go diff --git a/common/configtx/handlers/msp/config.go b/common/configvalues/msp/config.go similarity index 86% rename from common/configtx/handlers/msp/config.go rename to common/configvalues/msp/config.go index e4b78415e18..92e8feba458 100644 --- a/common/configtx/handlers/msp/config.go +++ b/common/configvalues/msp/config.go @@ -43,29 +43,29 @@ type MSPConfigHandler struct { // BeginConfig called when a config proposal is begun func (bh *MSPConfigHandler) BeginConfig() { if bh.pendingConfig != nil { - panic("Programming error, called BeginConfig while a proposal was in process") + panic("Programming error, called BeginValueProposals while a proposal was in process") } bh.pendingConfig = &mspConfigStore{ idMap: make(map[string]*pendingMSPConfig), } } -// RollbackConfig called when a config proposal is abandoned -func (bh *MSPConfigHandler) RollbackConfig() { +// RollbackProposals called when a config proposal is abandoned +func (bh *MSPConfigHandler) RollbackProposals() { bh.pendingConfig = nil } -// CommitConfig called when a config proposal is committed -func (bh *MSPConfigHandler) CommitConfig() { +// CommitProposals called when a config proposal is committed +func (bh *MSPConfigHandler) CommitProposals() { if bh.pendingConfig == nil { - panic("Programming error, called CommitConfig with no proposal in process") + panic("Programming error, called CommitProposals with no proposal in process") } bh.MSPManager = bh.pendingConfig.proposedMgr bh.pendingConfig = nil } -// ProposeConfig called when config is added to a proposal +// ProposeValue called when config is added to a proposal func (bh *MSPConfigHandler) ProposeMSP(mspConfig *mspprotos.MSPConfig) (msp.MSP, error) { // check that the type for that MSP is supported if mspConfig.Type != int32(msp.FABRIC) { diff --git a/common/configtx/handlers/msp/config_test.go b/common/configvalues/msp/config_test.go similarity index 92% rename from common/configtx/handlers/msp/config_test.go rename to common/configvalues/msp/config_test.go index 43d166e6174..52fe6254b02 100644 --- a/common/configtx/handlers/msp/config_test.go +++ b/common/configvalues/msp/config_test.go @@ -25,7 +25,7 @@ import ( ) func TestMSPConfigManager(t *testing.T) { - conf, err := msp.GetLocalMspConfig("../../../../msp/sampleconfig/", "DEFAULT") + conf, err := msp.GetLocalMspConfig("../../../msp/sampleconfig/", "DEFAULT") assert.NoError(t, err) // test success: @@ -35,7 +35,7 @@ func TestMSPConfigManager(t *testing.T) { mspCH.BeginConfig() _, err = mspCH.ProposeMSP(conf) assert.NoError(t, err) - mspCH.CommitConfig() + mspCH.CommitProposals() msps, err := mspCH.GetMSPs() assert.NoError(t, err) diff --git a/common/configtx/handlers/msp/config_util.go b/common/configvalues/msp/config_util.go similarity index 100% rename from common/configtx/handlers/msp/config_util.go rename to common/configvalues/msp/config_util.go diff --git a/common/mocks/configtx/configtx.go b/common/mocks/configtx/configtx.go index ea6bff97efc..3ad9200139c 100644 --- a/common/mocks/configtx/configtx.go +++ b/common/mocks/configtx/configtx.go @@ -18,6 +18,7 @@ package configtx import ( configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" mockpolicies "github.com/hyperledger/fabric/common/mocks/policies" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/msp" @@ -29,13 +30,13 @@ type Resources struct { PolicyManagerVal *mockpolicies.Manager // ChannelConfigVal is returned as the result of ChannelConfig() - ChannelConfigVal configtxapi.ChannelConfig + ChannelConfigVal configvaluesapi.Channel // OrdererConfigVal is returned as the result of OrdererConfig() - OrdererConfigVal configtxapi.OrdererConfig + OrdererConfigVal configvaluesapi.Orderer // ApplicationConfigVal is returned as the result of ApplicationConfig() - ApplicationConfigVal configtxapi.ApplicationConfig + ApplicationConfigVal configvaluesapi.Application // MSPManagerVal is returned as the result of MSPManager() MSPManagerVal msp.MSPManager @@ -47,17 +48,17 @@ func (r *Resources) PolicyManager() policies.Manager { } // Returns the ChannelConfigVal -func (r *Resources) ChannelConfig() configtxapi.ChannelConfig { +func (r *Resources) ChannelConfig() configvaluesapi.Channel { return r.ChannelConfigVal } // Returns the OrdererConfigVal -func (r *Resources) OrdererConfig() configtxapi.OrdererConfig { +func (r *Resources) OrdererConfig() configvaluesapi.Orderer { return r.OrdererConfigVal } // Returns the ApplicationConfigVal -func (r *Resources) ApplicationConfig() configtxapi.ApplicationConfig { +func (r *Resources) ApplicationConfig() configvaluesapi.Application { return r.ApplicationConfigVal } @@ -71,8 +72,8 @@ type Transactional struct { } // BeginConfig returns slices populated by HandlerVal -func (t *Transactional) BeginConfig(groups []string) ([]configtxapi.Handler, error) { - handlers := make([]configtxapi.Handler, len(groups)) +func (t *Transactional) BeginValueProposals(groups []string) ([]configvaluesapi.ValueProposer, error) { + handlers := make([]configvaluesapi.ValueProposer, len(groups)) for i := range handlers { handlers[i] = t.HandlerVal } @@ -80,10 +81,10 @@ func (t *Transactional) BeginConfig(groups []string) ([]configtxapi.Handler, err } // CommitConfig calls through to the HandlerVal -func (t *Transactional) CommitConfig() {} +func (t *Transactional) CommitProposals() {} // RollbackConfig calls through to the HandlerVal -func (t *Transactional) RollbackConfig() {} +func (t *Transactional) RollbackProposals() {} // Initializer mocks the configtxapi.Initializer interface type Initializer struct { @@ -116,6 +117,11 @@ func (ph *PolicyHandler) ProposePolicy(key string, path []string, configPolicy * return ph.ErrorForProposePolicy } +// BeginConfig will be removed in the future +func (ph *PolicyHandler) BeginConfig(groups []string) ([]configtxapi.PolicyHandler, error) { + return []configtxapi.PolicyHandler{ph}, nil +} + // Handler mocks the configtxapi.Handler interface type Handler struct { Transactional @@ -125,7 +131,7 @@ type Handler struct { } // ProposeConfig sets LastKey to key, and LastValue to configValue, returning ErrorForProposedConfig -func (h *Handler) ProposeConfig(key string, configValue *cb.ConfigValue) error { +func (h *Handler) ProposeValue(key string, configValue *cb.ConfigValue) error { h.LastKey = key h.LastValue = configValue return h.ErrorForProposeConfig diff --git a/common/mocks/configtx/configtx_test.go b/common/mocks/configtx/configtx_test.go index 6b6b58ad779..038bb456f8f 100644 --- a/common/mocks/configtx/configtx_test.go +++ b/common/mocks/configtx/configtx_test.go @@ -41,7 +41,3 @@ func TestConfigtxManagerInterface(t *testing.T) { func TestConfigtxResourcesInterface(t *testing.T) { _ = configtxapi.Resources(&Resources{}) } - -func TestConfigtxHandlerInterface(t *testing.T) { - _ = configtxapi.Handler(&Handler{}) -} diff --git a/common/mocks/configtx/handlers/orderer/sharedconfig.go b/common/mocks/configvalues/channel/orderer/sharedconfig.go similarity index 100% rename from common/mocks/configtx/handlers/orderer/sharedconfig.go rename to common/mocks/configvalues/channel/orderer/sharedconfig.go diff --git a/common/mocks/configtx/handlers/orderer/sharedconfig_test.go b/common/mocks/configvalues/channel/orderer/sharedconfig_test.go similarity index 85% rename from common/mocks/configtx/handlers/orderer/sharedconfig_test.go rename to common/mocks/configvalues/channel/orderer/sharedconfig_test.go index 71600c737a8..a24e87776bd 100644 --- a/common/mocks/configtx/handlers/orderer/sharedconfig_test.go +++ b/common/mocks/configvalues/channel/orderer/sharedconfig_test.go @@ -19,9 +19,9 @@ package sharedconfig import ( "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" ) func TestSharedConfigInterface(t *testing.T) { - _ = configtxapi.OrdererConfig(&SharedConfig{}) + _ = configvaluesapi.Orderer(&SharedConfig{}) } diff --git a/common/mocks/configtx/handlers/channel/sharedconfig.go b/common/mocks/configvalues/channel/sharedconfig.go similarity index 100% rename from common/mocks/configtx/handlers/channel/sharedconfig.go rename to common/mocks/configvalues/channel/sharedconfig.go diff --git a/common/mocks/configtx/handlers/channel/sharedconfig_test.go b/common/mocks/configvalues/channel/sharedconfig_test.go similarity index 85% rename from common/mocks/configtx/handlers/channel/sharedconfig_test.go rename to common/mocks/configvalues/channel/sharedconfig_test.go index dd45651f0d8..6d64a57497e 100644 --- a/common/mocks/configtx/handlers/channel/sharedconfig_test.go +++ b/common/mocks/configvalues/channel/sharedconfig_test.go @@ -19,9 +19,9 @@ package channel import ( "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" ) func TestChainConfigInterface(t *testing.T) { - _ = configtxapi.ChannelConfig(&SharedConfig{}) + _ = configvaluesapi.Channel(&SharedConfig{}) } diff --git a/common/policies/policy.go b/common/policies/policy.go index 34d1a589a55..7c39068c8bf 100644 --- a/common/policies/policy.go +++ b/common/policies/policy.go @@ -96,13 +96,13 @@ func (pm *ManagerImpl) BeginConfig(groups []string) ([]*ManagerImpl, error) { return nil, nil } -// RollbackConfig is used to abandon a new config proposal -func (pm *ManagerImpl) RollbackConfig() { +// RollbackProposals is used to abandon a new config proposal +func (pm *ManagerImpl) RollbackProposals() { pm.pendingPolicies = nil } -// CommitConfig is used to commit a new config proposal -func (pm *ManagerImpl) CommitConfig() { +// CommitProposals is used to commit a new config proposal +func (pm *ManagerImpl) CommitProposals() { if pm.pendingPolicies == nil { logger.Panicf("Programming error, cannot call commit without an existing proposal") } diff --git a/core/peer/peer.go b/core/peer/peer.go index 95c5495f8aa..3dde642bdb1 100644 --- a/core/peer/peer.go +++ b/core/peer/peer.go @@ -24,6 +24,7 @@ import ( "github.com/hyperledger/fabric/common/configtx" configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/core/comm" "github.com/hyperledger/fabric/core/committer" "github.com/hyperledger/fabric/core/committer/txvalidator" @@ -43,7 +44,7 @@ var peerLogger = logging.MustGetLogger("peer") type chainSupport struct { configtxapi.Manager - configtxapi.ApplicationConfig + configvaluesapi.Application ledger ledger.PeerLedger } @@ -165,8 +166,8 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error { gossipCallbackWrapper := func(cm configtxapi.Manager) { gossipEventer.ProcessConfigUpdate(&chainSupport{ - Manager: cm, - ApplicationConfig: configtxInitializer.ApplicationConfig(), + Manager: cm, + Application: configtxInitializer.ApplicationConfig(), }) } @@ -183,9 +184,9 @@ func createChain(cid string, ledger ledger.PeerLedger, cb *common.Block) error { mspmgmt.XXXSetMSPManager(cid, configtxManager.MSPManager()) cs := &chainSupport{ - Manager: configtxManager, - ApplicationConfig: configtxManager.ApplicationConfig(), // TODO, refactor as this is accessible through Manager - ledger: ledger, + Manager: configtxManager, + Application: configtxManager.ApplicationConfig(), // TODO, refactor as this is accessible through Manager + ledger: ledger, } c := committer.NewLedgerCommitter(ledger, txvalidator.NewTxValidator(cs)) diff --git a/gossip/service/eventer.go b/gossip/service/eventer.go index ee80deb0376..fccb11512ce 100644 --- a/gossip/service/eventer.go +++ b/gossip/service/eventer.go @@ -19,7 +19,7 @@ package service import ( "reflect" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/protos/peer" ) @@ -30,7 +30,7 @@ type Config interface { ChainID() string // Organizations returns a map of org ID to ApplicationOrgConfig - Organizations() map[string]configtxapi.ApplicationOrgConfig + Organizations() map[string]configvaluesapi.ApplicationOrg // Sequence should return the sequence number of the current configuration Sequence() uint64 @@ -44,7 +44,7 @@ type ConfigProcessor interface { type configStore struct { anchorPeers []*peer.AnchorPeer - orgMap map[string]configtxapi.ApplicationOrgConfig + orgMap map[string]configvaluesapi.ApplicationOrg } type configEventReceiver interface { diff --git a/gossip/service/eventer_test.go b/gossip/service/eventer_test.go index 2e6779bbe20..1764a034c6e 100644 --- a/gossip/service/eventer_test.go +++ b/gossip/service/eventer_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/protos/peer" ) @@ -41,7 +41,7 @@ func (ao applicationOrgs) Name() string { } type mockReceiver struct { - orgs map[string]configtxapi.ApplicationOrgConfig + orgs map[string]configvaluesapi.ApplicationOrg sequence uint64 } @@ -57,7 +57,7 @@ func (mc *mockConfig) Sequence() uint64 { return mc.sequence } -func (mc *mockConfig) Organizations() map[string]configtxapi.ApplicationOrgConfig { +func (mc *mockConfig) Organizations() map[string]configvaluesapi.ApplicationOrg { return mc.orgs } @@ -70,7 +70,7 @@ const testOrgID = "testID" func TestInitialUpdate(t *testing.T) { mc := &mockConfig{ sequence: 7, - orgs: map[string]configtxapi.ApplicationOrgConfig{ + orgs: map[string]configvaluesapi.ApplicationOrg{ testOrgID: applicationOrgs([]*peer.AnchorPeer{ &peer.AnchorPeer{ Port: 9, @@ -92,7 +92,7 @@ func TestInitialUpdate(t *testing.T) { func TestSecondUpdate(t *testing.T) { mc := &mockConfig{ sequence: 7, - orgs: map[string]configtxapi.ApplicationOrgConfig{ + orgs: map[string]configvaluesapi.ApplicationOrg{ testOrgID: applicationOrgs([]*peer.AnchorPeer{ &peer.AnchorPeer{ Port: 9, @@ -107,7 +107,7 @@ func TestSecondUpdate(t *testing.T) { ce.ProcessConfigUpdate(mc) mc.sequence = 8 - mc.orgs = map[string]configtxapi.ApplicationOrgConfig{ + mc.orgs = map[string]configvaluesapi.ApplicationOrg{ testOrgID: applicationOrgs([]*peer.AnchorPeer{ &peer.AnchorPeer{ Port: 10, @@ -125,7 +125,7 @@ func TestSecondUpdate(t *testing.T) { func TestSecondSameUpdate(t *testing.T) { mc := &mockConfig{ sequence: 7, - orgs: map[string]configtxapi.ApplicationOrgConfig{ + orgs: map[string]configvaluesapi.ApplicationOrg{ testOrgID: applicationOrgs([]*peer.AnchorPeer{ &peer.AnchorPeer{ Port: 9, @@ -154,7 +154,7 @@ func TestSecondSameUpdate(t *testing.T) { func TestUpdatedSeqOnly(t *testing.T) { mc := &mockConfig{ sequence: 7, - orgs: map[string]configtxapi.ApplicationOrgConfig{ + orgs: map[string]configvaluesapi.ApplicationOrg{ testOrgID: applicationOrgs([]*peer.AnchorPeer{ &peer.AnchorPeer{ Port: 9, diff --git a/orderer/common/blockcutter/blockcutter.go b/orderer/common/blockcutter/blockcutter.go index 0c555180104..8b18a5f09e6 100644 --- a/orderer/common/blockcutter/blockcutter.go +++ b/orderer/common/blockcutter/blockcutter.go @@ -17,7 +17,7 @@ limitations under the License. package blockcutter import ( - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/orderer/common/filter" cb "github.com/hyperledger/fabric/protos/common" @@ -52,7 +52,7 @@ type Receiver interface { } type receiver struct { - sharedConfigManager configtxapi.OrdererConfig + sharedConfigManager configvaluesapi.Orderer filters *filter.RuleSet pendingBatch []*cb.Envelope pendingBatchSizeBytes uint32 @@ -60,7 +60,7 @@ type receiver struct { } // NewReceiverImpl creates a Receiver implementation based on the given configtxorderer manager and filters -func NewReceiverImpl(sharedConfigManager configtxapi.OrdererConfig, filters *filter.RuleSet) Receiver { +func NewReceiverImpl(sharedConfigManager configvaluesapi.Orderer, filters *filter.RuleSet) Receiver { return &receiver{ sharedConfigManager: sharedConfigManager, filters: filters, diff --git a/orderer/common/blockcutter/blockcutter_test.go b/orderer/common/blockcutter/blockcutter_test.go index 459e856555b..6e2f34106df 100644 --- a/orderer/common/blockcutter/blockcutter_test.go +++ b/orderer/common/blockcutter/blockcutter_test.go @@ -20,7 +20,7 @@ import ( "bytes" "testing" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" "github.com/hyperledger/fabric/orderer/common/filter" cb "github.com/hyperledger/fabric/protos/common" ab "github.com/hyperledger/fabric/protos/orderer" diff --git a/orderer/common/deliver/deliver.go b/orderer/common/deliver/deliver.go index 39705456275..0b4c2ca73ec 100644 --- a/orderer/common/deliver/deliver.go +++ b/orderer/common/deliver/deliver.go @@ -19,7 +19,7 @@ package deliver import ( "fmt" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/filter" "github.com/hyperledger/fabric/orderer/common/sigfilter" @@ -52,7 +52,7 @@ type Support interface { Reader() ordererledger.Reader // SharedConfig returns the shared config manager for this chain - SharedConfig() configtxapi.OrdererConfig + SharedConfig() configvaluesapi.Orderer } type deliverServer struct { diff --git a/orderer/common/deliver/deliver_test.go b/orderer/common/deliver/deliver_test.go index 7e682053afc..7f80b102bba 100644 --- a/orderer/common/deliver/deliver_test.go +++ b/orderer/common/deliver/deliver_test.go @@ -21,10 +21,10 @@ import ( "testing" "time" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig" "github.com/hyperledger/fabric/common/configtx/tool/provisional" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" + mockconfigvaluesorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" mockpolicies "github.com/hyperledger/fabric/common/mocks/policies" "github.com/hyperledger/fabric/common/policies" ordererledger "github.com/hyperledger/fabric/orderer/ledger" @@ -84,7 +84,7 @@ func (mm *mockSupportManager) GetChain(chainID string) (Support, bool) { type mockSupport struct { ledger ordererledger.ReadWriter - sharedConfig *mockconfigtxorderer.SharedConfig + sharedConfig *mockconfigvaluesorderer.SharedConfig policyManager *mockpolicies.Manager } @@ -103,7 +103,7 @@ func NewRAMLedger() ordererledger.ReadWriter { return rl } -func (mcs *mockSupport) SharedConfig() configtxapi.OrdererConfig { +func (mcs *mockSupport) SharedConfig() configvaluesapi.Orderer { return mcs.sharedConfig } @@ -114,7 +114,7 @@ func newMockMultichainManager() *mockSupportManager { } mm.chains[systemChainID] = &mockSupport{ ledger: rl, - sharedConfig: &mockconfigtxorderer.SharedConfig{EgressPolicyNamesVal: []string{"somePolicy"}}, + sharedConfig: &mockconfigvaluesorderer.SharedConfig{EgressPolicyNamesVal: []string{"somePolicy"}}, policyManager: &mockpolicies.Manager{Policy: &mockpolicies.Policy{}}, } return mm diff --git a/orderer/kafka/orderer_test.go b/orderer/kafka/orderer_test.go index 06ceeace1a7..77790a8ae0c 100644 --- a/orderer/kafka/orderer_test.go +++ b/orderer/kafka/orderer_test.go @@ -24,7 +24,7 @@ import ( "github.com/Shopify/sarama" "github.com/hyperledger/fabric/common/configtx/tool/provisional" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + mockconfigvaluesorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" "github.com/hyperledger/fabric/orderer/localconfig" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" mockmultichain "github.com/hyperledger/fabric/orderer/mocks/multichain" @@ -36,8 +36,8 @@ import ( var cp = newChainPartition(provisional.TestChainID, rawPartition) -func newMockSharedConfigManager() *mockconfigtxorderer.SharedConfig { - return &mockconfigtxorderer.SharedConfig{KafkaBrokersVal: testGenesisConf.Orderer.Kafka.Brokers} +func newMockSharedConfigManager() *mockconfigvaluesorderer.SharedConfig { + return &mockconfigvaluesorderer.SharedConfig{KafkaBrokersVal: testGenesisConf.Orderer.Kafka.Brokers} } type mockConsenterImpl struct { @@ -132,7 +132,7 @@ func TestKafkaConsenterEmptyBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, } defer close(cs.BlockCutterVal.Block) @@ -167,7 +167,7 @@ func TestKafkaConsenterBatchTimer(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -219,7 +219,7 @@ func TestKafkaConsenterTimerHaltOnFilledBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -279,7 +279,7 @@ func TestKafkaConsenterConfigStyleMultiBatch(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: testTimePadding}, } defer close(cs.BlockCutterVal.Block) @@ -329,7 +329,7 @@ func TestKafkaConsenterTimeToCutForced(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -386,7 +386,7 @@ func TestKafkaConsenterTimeToCutDuplicate(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -475,7 +475,7 @@ func TestKafkaConsenterTimeToCutStale(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -534,7 +534,7 @@ func TestKafkaConsenterTimeToCutLarger(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) @@ -616,7 +616,7 @@ func TestKafkaConsenterRestart(t *testing.T) { Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), ChainIDVal: provisional.TestChainID, - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(cs.BlockCutterVal.Block) diff --git a/orderer/mocks/multichain/multichain.go b/orderer/mocks/multichain/multichain.go index 3e46accc1ad..426a5f2d758 100644 --- a/orderer/mocks/multichain/multichain.go +++ b/orderer/mocks/multichain/multichain.go @@ -17,8 +17,8 @@ limitations under the License. package multichain import ( - configtxapi "github.com/hyperledger/fabric/common/configtx/api" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" + mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" "github.com/hyperledger/fabric/orderer/common/blockcutter" "github.com/hyperledger/fabric/orderer/common/filter" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" @@ -58,7 +58,7 @@ func (mcs *ConsenterSupport) BlockCutter() blockcutter.Receiver { } // SharedConfig returns SharedConfigVal -func (mcs *ConsenterSupport) SharedConfig() configtxapi.OrdererConfig { +func (mcs *ConsenterSupport) SharedConfig() configvaluesapi.Orderer { return mcs.SharedConfigVal } diff --git a/orderer/multichain/chainsupport.go b/orderer/multichain/chainsupport.go index b622f21e9fd..c21bea57aff 100644 --- a/orderer/multichain/chainsupport.go +++ b/orderer/multichain/chainsupport.go @@ -17,7 +17,7 @@ limitations under the License. package multichain import ( - configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" "github.com/hyperledger/fabric/common/crypto" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/common/util" @@ -66,7 +66,7 @@ type Chain interface { type ConsenterSupport interface { crypto.LocalSigner BlockCutter() blockcutter.Receiver - SharedConfig() configtxapi.OrdererConfig + SharedConfig() configvaluesapi.Orderer CreateNextBlock(messages []*cb.Envelope) *cb.Block WriteBlock(block *cb.Block, committers []filter.Committer, encodedMetadataValue []byte) *cb.Block ChainID() string // ChainID returns the chain ID this specific consenter instance is associated with diff --git a/orderer/multichain/manager.go b/orderer/multichain/manager.go index 9b5ec85a9d6..89a25e60a6e 100644 --- a/orderer/multichain/manager.go +++ b/orderer/multichain/manager.go @@ -21,6 +21,7 @@ import ( "github.com/hyperledger/fabric/common/configtx" configtxapi "github.com/hyperledger/fabric/common/configtx/api" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" ordererledger "github.com/hyperledger/fabric/orderer/ledger" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" @@ -47,7 +48,7 @@ type configResources struct { configtxapi.Manager } -func (cr *configResources) SharedConfig() configtxapi.OrdererConfig { +func (cr *configResources) SharedConfig() configvaluesapi.Orderer { return cr.OrdererConfig() } diff --git a/orderer/multichain/systemchain.go b/orderer/multichain/systemchain.go index 0615534b3cc..a63e0a549de 100644 --- a/orderer/multichain/systemchain.go +++ b/orderer/multichain/systemchain.go @@ -18,8 +18,8 @@ package multichain import ( "github.com/hyperledger/fabric/common/configtx" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/filter" cb "github.com/hyperledger/fabric/protos/common" @@ -38,8 +38,8 @@ type chainCreator interface { type limitedSupport interface { ChainID() string PolicyManager() policies.Manager - SharedConfig() configtxapi.OrdererConfig - ChannelConfig() configtxapi.ChannelConfig + SharedConfig() configvaluesapi.Orderer + ChannelConfig() configvaluesapi.Channel Enqueue(env *cb.Envelope) bool } diff --git a/orderer/multichain/systemchain_test.go b/orderer/multichain/systemchain_test.go index 96e8418540e..654064277e6 100644 --- a/orderer/multichain/systemchain_test.go +++ b/orderer/multichain/systemchain_test.go @@ -21,10 +21,10 @@ import ( "testing" "github.com/hyperledger/fabric/common/configtx" - configtxapi "github.com/hyperledger/fabric/common/configtx/api" "github.com/hyperledger/fabric/common/configtx/tool/provisional" - mockconfigtxchannel "github.com/hyperledger/fabric/common/mocks/configtx/handlers/channel" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + configvaluesapi "github.com/hyperledger/fabric/common/configvalues/api" + mockconfigvalueschannel "github.com/hyperledger/fabric/common/mocks/configvalues/channel" + mockconfigvaluesorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" "github.com/hyperledger/fabric/common/policies" "github.com/hyperledger/fabric/orderer/common/filter" cb "github.com/hyperledger/fabric/protos/common" @@ -49,18 +49,18 @@ func (mpm *mockPolicyManager) GetPolicy(id string) (policies.Policy, bool) { type mockSupport struct { mpm *mockPolicyManager - msc *mockconfigtxorderer.SharedConfig + msc *mockconfigvaluesorderer.SharedConfig chainID string queue []*cb.Envelope - chainConfig *mockconfigtxchannel.SharedConfig + chainConfig *mockconfigvalueschannel.SharedConfig } func newMockSupport(chainID string) *mockSupport { return &mockSupport{ mpm: &mockPolicyManager{}, - msc: &mockconfigtxorderer.SharedConfig{}, + msc: &mockconfigvaluesorderer.SharedConfig{}, chainID: chainID, - chainConfig: &mockconfigtxchannel.SharedConfig{}, + chainConfig: &mockconfigvalueschannel.SharedConfig{}, } } @@ -77,11 +77,11 @@ func (ms *mockSupport) PolicyManager() policies.Manager { return ms.mpm } -func (ms *mockSupport) SharedConfig() configtxapi.OrdererConfig { +func (ms *mockSupport) SharedConfig() configvaluesapi.Orderer { return ms.msc } -func (ms *mockSupport) ChannelConfig() configtxapi.ChannelConfig { +func (ms *mockSupport) ChannelConfig() configvaluesapi.Channel { return ms.chainConfig } diff --git a/orderer/multichain/util_test.go b/orderer/multichain/util_test.go index a2081658cf5..fbf4ddd979d 100644 --- a/orderer/multichain/util_test.go +++ b/orderer/multichain/util_test.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/hyperledger/fabric/common/configtx" - configtxorderer "github.com/hyperledger/fabric/common/configtx/handlers/orderer" + configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer" "github.com/hyperledger/fabric/orderer/common/blockcutter" cb "github.com/hyperledger/fabric/protos/common" "github.com/hyperledger/fabric/protos/utils" diff --git a/orderer/solo/consensus_test.go b/orderer/solo/consensus_test.go index 81831179cc8..d638d253269 100644 --- a/orderer/solo/consensus_test.go +++ b/orderer/solo/consensus_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - mockconfigtxorderer "github.com/hyperledger/fabric/common/mocks/configtx/handlers/orderer" + mockconfigvaluesorderer "github.com/hyperledger/fabric/common/mocks/configvalues/channel/orderer" mockblockcutter "github.com/hyperledger/fabric/orderer/mocks/blockcutter" mockmultichain "github.com/hyperledger/fabric/orderer/mocks/multichain" cb "github.com/hyperledger/fabric/protos/common" @@ -59,7 +59,7 @@ func TestEmptyBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support) @@ -80,7 +80,7 @@ func TestBatchTimer(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support) @@ -115,7 +115,7 @@ func TestBatchTimerHaltOnFilledBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) @@ -158,7 +158,7 @@ func TestConfigStyleMultiBatch(t *testing.T) { support := &mockmultichain.ConsenterSupport{ Batches: make(chan []*cb.Envelope), BlockCutterVal: mockblockcutter.NewReceiver(), - SharedConfigVal: &mockconfigtxorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, + SharedConfigVal: &mockconfigvaluesorderer.SharedConfig{BatchTimeoutVal: batchTimeout}, } defer close(support.BlockCutterVal.Block) bs := newChain(support) diff --git a/peer/channel/create.go b/peer/channel/create.go index 91210874a64..c8318d161b8 100644 --- a/peer/channel/create.go +++ b/peer/channel/create.go @@ -22,9 +22,9 @@ import ( "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/common/configtx" - configtxapplication "github.com/hyperledger/fabric/common/configtx/handlers/application" configtxtest "github.com/hyperledger/fabric/common/configtx/test" "github.com/hyperledger/fabric/common/configtx/tool/provisional" + configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application" mspmgmt "github.com/hyperledger/fabric/msp/mgmt" "github.com/hyperledger/fabric/peer/common" cb "github.com/hyperledger/fabric/protos/common"