Skip to content

Commit bcb9259

Browse files
author
Jason Yellick
committed
[FAB-2526] Move consolidate config to one package
https://jira.hyperledger.org/browse/FAB-2526 This CR consolidates config from fabric/common/configvalues/root and fabric/common/configvalues to be in fabric/common/config. This completes the refactoring of the config needed to support config inspection which will follow in subsequent changesets. Change-Id: I081547be49abc3d0839f0b3accd01d378f36bf81 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent efa8237 commit bcb9259

Some content is hidden

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

44 files changed

+116
-118
lines changed

common/configvalues/api.go renamed to common/config/api.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ type Application interface {
4949
Organizations() map[string]ApplicationOrg
5050
}
5151

52+
// Channel gives read only access to the channel configuration
53+
type Channel interface {
54+
// HashingAlgorithm returns the default algorithm to be used when hashing
55+
// such as computing block hashes, and CreationPolicy digests
56+
HashingAlgorithm() func(input []byte) []byte
57+
58+
// BlockDataHashingStructureWidth returns the width to use when constructing the
59+
// Merkle tree to compute the BlockData hash
60+
BlockDataHashingStructureWidth() uint32
61+
62+
// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver
63+
OrdererAddresses() []string
64+
}
65+
5266
// Orderer stores the common shared orderer config
5367
type Orderer interface {
5468
// ConsensusType returns the configured consensus type

common/configvalues/root/application.go renamed to common/config/application.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ package config
1919
import (
2020
"fmt"
2121

22-
api "github.com/hyperledger/fabric/common/configvalues"
23-
"github.com/hyperledger/fabric/common/configvalues/msp"
22+
"github.com/hyperledger/fabric/common/config/msp"
2423
)
2524

2625
const (
@@ -39,7 +38,7 @@ type ApplicationConfig struct {
3938
*standardValues
4039

4140
applicationGroup *ApplicationGroup
42-
applicationOrgs map[string]api.ApplicationOrg
41+
applicationOrgs map[string]ApplicationOrg
4342
}
4443

4544
// NewSharedConfigImpl creates a new SharedConfigImpl with the given CryptoHelper
@@ -52,7 +51,7 @@ func NewApplicationGroup(mspConfig *msp.MSPConfigHandler) *ApplicationGroup {
5251
return ag
5352
}
5453

55-
func (ag *ApplicationGroup) NewGroup(name string) (api.ValueProposer, error) {
54+
func (ag *ApplicationGroup) NewGroup(name string) (ValueProposer, error) {
5655
return NewApplicationOrgGroup(name, ag.mspConfig), nil
5756
}
5857

@@ -75,8 +74,8 @@ func NewApplicationConfig(ag *ApplicationGroup) *ApplicationConfig {
7574
}
7675
}
7776

78-
func (ac *ApplicationConfig) Validate(groups map[string]api.ValueProposer) error {
79-
ac.applicationOrgs = make(map[string]api.ApplicationOrg)
77+
func (ac *ApplicationConfig) Validate(groups map[string]ValueProposer) error {
78+
ac.applicationOrgs = make(map[string]ApplicationOrg)
8079
var ok bool
8180
for key, value := range groups {
8281
ac.applicationOrgs[key], ok = value.(*ApplicationOrgGroup)
@@ -92,6 +91,6 @@ func (ac *ApplicationConfig) Commit() {
9291
}
9392

9493
// Organizations returns a map of org ID to ApplicationOrg
95-
func (ac *ApplicationConfig) Organizations() map[string]api.ApplicationOrg {
94+
func (ac *ApplicationConfig) Organizations() map[string]ApplicationOrg {
9695
return ac.applicationOrgs
9796
}

common/configvalues/root/application_test.go renamed to common/config/application_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package config
1919
import (
2020
"testing"
2121

22-
api "github.com/hyperledger/fabric/common/configvalues"
23-
2422
logging "github.com/op/go-logging"
2523
)
2624

@@ -29,5 +27,5 @@ func init() {
2927
}
3028

3129
func TestApplicationInterface(t *testing.T) {
32-
_ = api.Application((*ApplicationGroup)(nil))
30+
_ = Application((*ApplicationGroup)(nil))
3331
}

common/configvalues/root/applicationorg.go renamed to common/config/applicationorg.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ limitations under the License.
1717
package config
1818

1919
import (
20-
api "github.com/hyperledger/fabric/common/configvalues"
21-
mspconfig "github.com/hyperledger/fabric/common/configvalues/msp"
20+
mspconfig "github.com/hyperledger/fabric/common/config/msp"
2221
pb "github.com/hyperledger/fabric/protos/peer"
2322

2423
logging "github.com/op/go-logging"
@@ -87,7 +86,7 @@ func NewApplicationOrgConfig(aog *ApplicationOrgGroup) *ApplicationOrgConfig {
8786
return aoc
8887
}
8988

90-
func (aoc *ApplicationOrgConfig) Validate(groups map[string]api.ValueProposer) error {
89+
func (aoc *ApplicationOrgConfig) Validate(groups map[string]ValueProposer) error {
9190
if logger.IsEnabledFor(logging.DEBUG) {
9291
logger.Debugf("Anchor peers for org %s are %v", aoc.applicationOrgGroup.name, aoc.protos.AnchorPeers)
9392
}

common/configvalues/root/applicationorg_test.go renamed to common/config/applicationorg_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ package config
1818

1919
import (
2020
"testing"
21-
22-
api "github.com/hyperledger/fabric/common/configvalues"
2321
)
2422

2523
func TestApplicationOrgInterface(t *testing.T) {
26-
_ = api.ValueProposer(NewApplicationOrgGroup("id", nil))
24+
_ = ValueProposer(NewApplicationOrgGroup("id", nil))
2725
}

common/configvalues/root/channel.go renamed to common/config/channel.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import (
2121
"math"
2222

2323
"github.com/hyperledger/fabric/bccsp"
24-
api "github.com/hyperledger/fabric/common/configvalues"
25-
"github.com/hyperledger/fabric/common/configvalues/msp"
24+
"github.com/hyperledger/fabric/common/config/msp"
2625
"github.com/hyperledger/fabric/common/util"
2726
cb "github.com/hyperledger/fabric/protos/common"
2827
)
@@ -107,7 +106,7 @@ func (cg *ChannelGroup) ApplicationConfig() *ApplicationGroup {
107106
}
108107

109108
// NewGroup instantiates either a new application or orderer config
110-
func (cg *ChannelGroup) NewGroup(group string) (api.ValueProposer, error) {
109+
func (cg *ChannelGroup) NewGroup(group string) (ValueProposer, error) {
111110
switch group {
112111
case ApplicationGroupKey:
113112
return NewApplicationGroup(cg.mspConfigHandler), nil
@@ -160,7 +159,7 @@ func (cc *ChannelConfig) OrdererAddresses() []string {
160159

161160
// Validate inspects the generated configuration protos, ensures that the values are correct, and
162161
// sets the ChannelConfig fields that may be referenced after Commit
163-
func (cc *ChannelConfig) Validate(groups map[string]api.ValueProposer) error {
162+
func (cc *ChannelConfig) Validate(groups map[string]ValueProposer) error {
164163
for _, validator := range []func() error{
165164
cc.validateHashingAlgorithm,
166165
cc.validateBlockDataHashingStructure,

common/configvalues/root/channel_test.go renamed to common/config/channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232
}
3333

3434
func TestInterface(t *testing.T) {
35-
_ = ChannelValues(NewChannelGroup(nil))
35+
_ = Channel(NewChannelGroup(nil))
3636
}
3737

3838
func TestHashingAlgorithm(t *testing.T) {
File renamed without changes.

0 commit comments

Comments
 (0)