@@ -23,20 +23,17 @@ import (
23
23
"github.com/hyperledger/fabric/common/configtx/api"
24
24
configvaluesapi "github.com/hyperledger/fabric/common/configvalues"
25
25
configvalueschannel "github.com/hyperledger/fabric/common/configvalues/channel"
26
- configtxapplication "github.com/hyperledger/fabric/common/configvalues/channel/application"
27
- configtxorderer "github.com/hyperledger/fabric/common/configvalues/channel/orderer"
28
26
configtxmsp "github.com/hyperledger/fabric/common/configvalues/msp"
27
+ configvaluesroot "github.com/hyperledger/fabric/common/configvalues/root"
29
28
"github.com/hyperledger/fabric/common/policies"
30
29
"github.com/hyperledger/fabric/msp"
31
30
cb "github.com/hyperledger/fabric/protos/common"
32
31
)
33
32
34
33
type resources struct {
35
- policyManager * policies.ManagerImpl
36
- channelConfig * configvalueschannel.Config
37
- ordererConfig * configtxorderer.ManagerImpl
38
- applicationConfig * configtxapplication.SharedConfigImpl
39
- mspConfigHandler * configtxmsp.MSPConfigHandler
34
+ policyManager * policies.ManagerImpl
35
+ configRoot * configvaluesroot.Root
36
+ mspConfigHandler * configtxmsp.MSPConfigHandler
40
37
}
41
38
42
39
// PolicyManager returns the policies.Manager for the chain
@@ -46,17 +43,17 @@ func (r *resources) PolicyManager() policies.Manager {
46
43
47
44
// ChannelConfig returns the api.ChannelConfig for the chain
48
45
func (r * resources ) ChannelConfig () configvalueschannel.ConfigReader {
49
- return r .channelConfig
46
+ return r .configRoot . Channel ()
50
47
}
51
48
52
49
// OrdererConfig returns the api.OrdererConfig for the chain
53
50
func (r * resources ) OrdererConfig () configvaluesapi.Orderer {
54
- return r .ordererConfig
51
+ return r .configRoot . Orderer ()
55
52
}
56
53
57
54
// ApplicationConfig returns the api.ApplicationConfig for the chain
58
55
func (r * resources ) ApplicationConfig () configvaluesapi.Application {
59
- return r .applicationConfig
56
+ return r .configRoot . Application ()
60
57
}
61
58
62
59
// MSPManager returns the msp.MSPManager for the chain
@@ -80,59 +77,17 @@ func newResources() *resources {
80
77
}
81
78
}
82
79
83
- ordererConfig := configtxorderer .NewManagerImpl (mspConfigHandler )
84
- applicationConfig := configtxapplication .NewSharedConfigImpl (mspConfigHandler )
85
-
86
80
return & resources {
87
- policyManager : policies .NewManagerImpl (RootGroupKey , policyProviderMap ),
88
- channelConfig : configvalueschannel .NewConfig (ordererConfig , applicationConfig ),
89
- ordererConfig : ordererConfig ,
90
- applicationConfig : applicationConfig ,
91
- mspConfigHandler : mspConfigHandler ,
81
+ policyManager : policies .NewManagerImpl (RootGroupKey , policyProviderMap ),
82
+ configRoot : configvaluesroot .NewRoot (mspConfigHandler ),
83
+ mspConfigHandler : mspConfigHandler ,
92
84
}
93
85
}
94
86
95
- type valueProposerRoot struct {
96
- channelConfig * configvalueschannel.Config
97
- mspConfigHandler * configtxmsp.MSPConfigHandler
98
- }
99
-
100
87
type policyProposerRoot struct {
101
88
policyManager policies.Proposer
102
89
}
103
90
104
- // BeginValueProposals is used to start a new config proposal
105
- func (v * valueProposerRoot ) BeginValueProposals (groups []string ) ([]configvaluesapi.ValueProposer , error ) {
106
- if len (groups ) != 1 {
107
- logger .Panicf ("Initializer only supports having one root group" )
108
- }
109
- logger .Debugf ("Calling begin for MSP manager" )
110
- v .mspConfigHandler .BeginConfig ()
111
- return []configvaluesapi.ValueProposer {v .channelConfig }, nil
112
- }
113
-
114
- // RollbackConfig is used to abandon a new config proposal
115
- func (i * valueProposerRoot ) RollbackProposals () {
116
- logger .Debugf ("Calling rollback for MSP manager" )
117
- i .mspConfigHandler .RollbackProposals ()
118
- }
119
-
120
- // PreCommit is used to verify total configuration before commit
121
- func (i * valueProposerRoot ) PreCommit () error {
122
- logger .Debugf ("Calling pre commit for MSP manager" )
123
- return i .mspConfigHandler .PreCommit ()
124
- }
125
-
126
- // CommitConfig is used to commit a new config proposal
127
- func (i * valueProposerRoot ) CommitProposals () {
128
- logger .Debugf ("Calling commit for MSP manager" )
129
- i .mspConfigHandler .CommitProposals ()
130
- }
131
-
132
- func (i * valueProposerRoot ) ProposeValue (key string , value * cb.ConfigValue ) error {
133
- return fmt .Errorf ("Programming error, this should never be invoked" )
134
- }
135
-
136
91
// BeginPolicyProposals is used to start a new config proposal
137
92
func (p * policyProposerRoot ) BeginPolicyProposals (groups []string ) ([]policies.Proposer , error ) {
138
93
if len (groups ) != 1 {
@@ -158,7 +113,6 @@ func (i *policyProposerRoot) CommitProposals() {}
158
113
159
114
type initializer struct {
160
115
* resources
161
- vpr * valueProposerRoot
162
116
ppr * policyProposerRoot
163
117
}
164
118
@@ -167,10 +121,6 @@ func NewInitializer() api.Initializer {
167
121
resources := newResources ()
168
122
return & initializer {
169
123
resources : resources ,
170
- vpr : & valueProposerRoot {
171
- channelConfig : resources .channelConfig ,
172
- mspConfigHandler : resources .mspConfigHandler ,
173
- },
174
124
ppr : & policyProposerRoot {
175
125
policyManager : resources .policyManager ,
176
126
},
@@ -182,5 +132,5 @@ func (i *initializer) PolicyProposer() policies.Proposer {
182
132
}
183
133
184
134
func (i * initializer ) ValueProposer () configvaluesapi.ValueProposer {
185
- return i .vpr
135
+ return i .resources . configRoot
186
136
}
0 commit comments