@@ -38,13 +38,14 @@ func NewConfigResult(config *cb.ConfigGroup, proposer api.Proposer) (ConfigResul
38
38
}
39
39
40
40
type configResult struct {
41
- tx interface {}
42
- groupName string
43
- group * cb.ConfigGroup
44
- valueHandler config.ValueProposer
45
- policyHandler policies.Proposer
46
- subResults []* configResult
47
- deserializedValues map [string ]proto.Message
41
+ tx interface {}
42
+ groupName string
43
+ group * cb.ConfigGroup
44
+ valueHandler config.ValueProposer
45
+ policyHandler policies.Proposer
46
+ subResults []* configResult
47
+ deserializedValues map [string ]proto.Message
48
+ deserializedPolicies map [string ]proto.Message
48
49
}
49
50
50
51
func (cr * configResult ) JSON () string {
@@ -101,6 +102,40 @@ func (cr *configResult) bufferJSON(buffer *bytes.Buffer) {
101
102
// },
102
103
buffer .WriteString ("}," )
103
104
105
+ count = 0
106
+ // "Policies": {
107
+ buffer .WriteString ("\" Policies\" : {" )
108
+ for key , policy := range cr .group .Policies {
109
+ // "Key": {
110
+ buffer .WriteString ("\" " )
111
+ buffer .WriteString (key )
112
+ buffer .WriteString ("\" : {" )
113
+ // "Version": "X",
114
+ buffer .WriteString ("\" Version\" :\" " )
115
+ buffer .WriteString (fmt .Sprintf ("%d" , policy .Version ))
116
+ buffer .WriteString ("\" ," )
117
+ // "ModPolicy": "foo",
118
+ buffer .WriteString ("\" ModPolicy\" :\" " )
119
+ buffer .WriteString (policy .ModPolicy )
120
+ buffer .WriteString ("\" ," )
121
+ // "Policy": {
122
+ buffer .WriteString ("\" Policy\" :{" )
123
+ // "PolicyType" :
124
+ buffer .WriteString (fmt .Sprintf ("\" PolicyType\" :\" %d\" ," , policy .Policy .Type ))
125
+ // "Policy" : policyAsJSON
126
+ buffer .WriteString ("\" Policy\" :" )
127
+ jpb .Marshal (buffer , cr .deserializedPolicies [key ])
128
+ // }
129
+ // },
130
+ buffer .WriteString ("}}" )
131
+ count ++
132
+ if count < len (cr .group .Policies ) {
133
+ buffer .WriteString ("," )
134
+ }
135
+ }
136
+ // },
137
+ buffer .WriteString ("}," )
138
+
104
139
// "Groups": {
105
140
count = 0
106
141
buffer .WriteString ("\" Groups\" : {" )
@@ -181,22 +216,25 @@ func proposeGroup(result *configResult) error {
181
216
}
182
217
183
218
for key , policy := range result .group .Policies {
184
- if err := result .policyHandler .ProposePolicy (result .tx , key , policy ); err != nil {
219
+ policy , err := result .policyHandler .ProposePolicy (result .tx , key , policy )
220
+ if err != nil {
185
221
result .rollback ()
186
222
return err
187
223
}
224
+ result .deserializedPolicies [key ] = policy
188
225
}
189
226
190
227
result .subResults = make ([]* configResult , 0 , len (subGroups ))
191
228
192
229
for i , subGroup := range subGroups {
193
230
result .subResults = append (result .subResults , & configResult {
194
- tx : result .tx ,
195
- groupName : result .groupName + "/" + subGroup ,
196
- group : result .group .Groups [subGroup ],
197
- valueHandler : subValueHandlers [i ],
198
- policyHandler : subPolicyHandlers [i ],
199
- deserializedValues : make (map [string ]proto.Message ),
231
+ tx : result .tx ,
232
+ groupName : result .groupName + "/" + subGroup ,
233
+ group : result .group .Groups [subGroup ],
234
+ valueHandler : subValueHandlers [i ],
235
+ policyHandler : subPolicyHandlers [i ],
236
+ deserializedValues : make (map [string ]proto.Message ),
237
+ deserializedPolicies : make (map [string ]proto.Message ),
200
238
})
201
239
202
240
if err := proposeGroup (result .subResults [i ]); err != nil {
0 commit comments