-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-2477] Move application config to Proposer
https://jira.hyperledger.org/browse/FAB-2477 This CR continues the cleanup of the assorted config handlers, this time for the application config. There is a noticable reduction in code complexity as the application config currently has no values, only sub-groups. Change-Id: I40295c7c46a51284ddbaca317bc8ba494c04a628 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Mar 7, 2017
1 parent
c8ff4b1
commit b609bf0
Showing
11 changed files
with
127 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 0 additions & 126 deletions
126
common/configvalues/channel/application/sharedconfig.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
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 config | ||
|
||
import ( | ||
"fmt" | ||
|
||
api "github.com/hyperledger/fabric/common/configvalues" | ||
"github.com/hyperledger/fabric/common/configvalues/msp" | ||
) | ||
|
||
const ( | ||
// ApplicationGroupKey is the group name for the Application config | ||
ApplicationGroupKey = "Application" | ||
) | ||
|
||
// ApplicationGroup represents the application config group | ||
type ApplicationGroup struct { | ||
*Proposer | ||
*ApplicationConfig | ||
mspConfig *msp.MSPConfigHandler | ||
} | ||
|
||
type ApplicationConfig struct { | ||
*standardValues | ||
|
||
applicationGroup *ApplicationGroup | ||
applicationOrgs map[string]api.ApplicationOrg | ||
} | ||
|
||
// NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper | ||
func NewApplicationGroup(mspConfig *msp.MSPConfigHandler) *ApplicationGroup { | ||
ag := &ApplicationGroup{ | ||
mspConfig: mspConfig, | ||
} | ||
ag.Proposer = NewProposer(ag) | ||
|
||
return ag | ||
} | ||
|
||
func (ag *ApplicationGroup) NewGroup(name string) (api.ValueProposer, error) { | ||
return NewApplicationOrgConfig(name, ag.mspConfig), nil | ||
} | ||
|
||
// Allocate returns the | ||
func (ag *ApplicationGroup) Allocate() Values { | ||
return NewApplicationConfig(ag) | ||
} | ||
|
||
func NewApplicationConfig(ag *ApplicationGroup) *ApplicationConfig { | ||
sv, err := NewStandardValues(&(struct{}{})) | ||
if err != nil { | ||
logger.Panicf("Programming error: %s", err) | ||
} | ||
|
||
return &ApplicationConfig{ | ||
applicationGroup: ag, | ||
|
||
// Currently there are no config values | ||
standardValues: sv, | ||
} | ||
} | ||
|
||
func (ac *ApplicationConfig) Validate(groups map[string]api.ValueProposer) error { | ||
ac.applicationOrgs = make(map[string]api.ApplicationOrg) | ||
var ok bool | ||
for key, value := range groups { | ||
ac.applicationOrgs[key], ok = value.(*ApplicationOrgConfig) | ||
if !ok { | ||
return fmt.Errorf("Application sub-group %s was not an ApplicationOrgGroup, actually %T", key, value) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (ac *ApplicationConfig) Commit() { | ||
ac.applicationGroup.ApplicationConfig = ac | ||
} | ||
|
||
// Organizations returns a map of org ID to ApplicationOrg | ||
func (ac *ApplicationConfig) Organizations() map[string]api.ApplicationOrg { | ||
return ac.applicationOrgs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.