Skip to content

Commit 226c0e9

Browse files
author
Jason Yellick
committedAug 30, 2017
[FAB-5811] Move configtxlator to new channelconfig
Just like with the orderer, the dependencies on the old mutable channel config mechanism must be removed. This CR moves the configtxlator code from using the older mutable model to the new immutable one. Change-Id: Ie087c41e1c660ad427531ba68bcf797c0b4efbc2 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent b70f66b commit 226c0e9

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed
 

‎common/channelconfig/bundle.go

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ SPDX-License-Identifier: Apache-2.0
77
package channelconfig
88

99
import (
10+
"fmt"
11+
1012
"github.com/hyperledger/fabric/common/cauthdsl"
1113
"github.com/hyperledger/fabric/common/config"
1214
oldchannelconfig "github.com/hyperledger/fabric/common/config/channel"
@@ -147,6 +149,14 @@ func (np noopProposer) PolicyManager() policies.Manager {
147149

148150
// NewBundle creates a new immutable bundle of configuration
149151
func NewBundle(channelID string, config *cb.Config) (*Bundle, error) {
152+
if config == nil {
153+
return nil, fmt.Errorf("config cannot be nil")
154+
}
155+
156+
if config.ChannelGroup == nil {
157+
return nil, fmt.Errorf("config must contain a channel group")
158+
}
159+
150160
mspConfigHandler := oldmspconfig.NewMSPConfigHandler()
151161
rootConfig := oldchannelconfig.NewRoot(mspConfigHandler)
152162

‎common/tools/configtxlator/sanitycheck/sanitycheck.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ package sanitycheck
1919
import (
2020
"fmt"
2121

22-
channelconfig "github.com/hyperledger/fabric/common/config/channel"
22+
newchannelconfig "github.com/hyperledger/fabric/common/channelconfig"
2323
cb "github.com/hyperledger/fabric/protos/common"
2424
mspprotos "github.com/hyperledger/fabric/protos/msp"
25-
"github.com/hyperledger/fabric/protos/utils"
2625

2726
"github.com/golang/protobuf/proto"
2827
)
@@ -39,14 +38,9 @@ type ElementMessage struct {
3938
}
4039

4140
func Check(config *cb.Config) (*Messages, error) {
42-
envConfig, err := utils.CreateSignedEnvelope(cb.HeaderType_CONFIG, "sanitycheck", nil, &cb.ConfigEnvelope{Config: config}, 0, 0)
43-
if err != nil {
44-
return nil, err
45-
}
46-
4741
result := &Messages{}
4842

49-
cm, err := channelconfig.New(envConfig, nil)
43+
bundle, err := newchannelconfig.NewBundle("sanitycheck", config)
5044
if err != nil {
5145
result.GeneralErrors = []string{err.Error()}
5246
return result, nil
@@ -57,13 +51,13 @@ func Check(config *cb.Config) (*Messages, error) {
5751
// we collect this manually.
5852
mspMap := make(map[string]struct{})
5953

60-
if ac, ok := cm.ApplicationConfig(); ok {
54+
if ac, ok := bundle.ApplicationConfig(); ok {
6155
for _, org := range ac.Organizations() {
6256
mspMap[org.MSPID()] = struct{}{}
6357
}
6458
}
6559

66-
if oc, ok := cm.OrdererConfig(); ok {
60+
if oc, ok := bundle.OrdererConfig(); ok {
6761
for _, org := range oc.Organizations() {
6862
mspMap[org.MSPID()] = struct{}{}
6963
}

0 commit comments

Comments
 (0)
Please sign in to comment.