@@ -30,26 +30,34 @@ import (
30
30
)
31
31
32
32
const (
33
+ // CreationPolicyKey defines the config key used in the channel
34
+ // config, under which the creation policy is defined.
33
35
CreationPolicyKey = "CreationPolicy"
34
36
msgVersion = int32 (0 )
35
37
epoch = 0
36
38
39
+ // ApplicationGroup identifies the `groups` map key in the channel
40
+ // config, under which the application-related config group is set.
37
41
ApplicationGroup = "Application"
38
- OrdererGroup = "Orderer"
39
- MSPKey = "MSP"
42
+ // OrdererGroup identifies the `groups` map key in the channel
43
+ // config, under which the orderer-related config group is set.
44
+ OrdererGroup = "Orderer"
45
+ // MSPKey identifies the config key in the channel config,
46
+ // under which the application-related config group is set.
47
+ MSPKey = "MSP"
40
48
)
41
49
42
50
// Template can be used to faciliate creation of config transactions
43
51
type Template interface {
44
- // Items returns a set of ConfigUpdateEnvelopes for the given chainID
52
+ // Envelope returns a ConfigUpdateEnvelope for the given chainID
45
53
Envelope (chainID string ) (* cb.ConfigUpdateEnvelope , error )
46
54
}
47
55
48
56
type simpleTemplate struct {
49
57
configGroup * cb.ConfigGroup
50
58
}
51
59
52
- // NewSimpleTemplate creates a Template using the supplied ConfigGroup
60
+ // NewSimpleTemplate creates a Template using the supplied ConfigGroups
53
61
func NewSimpleTemplate (configGroups ... * cb.ConfigGroup ) Template {
54
62
sts := make ([]Template , len (configGroups ))
55
63
for i , group := range configGroups {
@@ -60,7 +68,7 @@ func NewSimpleTemplate(configGroups ...*cb.ConfigGroup) Template {
60
68
return NewCompositeTemplate (sts ... )
61
69
}
62
70
63
- // Envelope returns a ConfigUpdateEnvelopes for the given chainID
71
+ // Envelope returns a ConfigUpdateEnvelope for the given chainID
64
72
func (st * simpleTemplate ) Envelope (chainID string ) (* cb.ConfigUpdateEnvelope , error ) {
65
73
config , err := proto .Marshal (& cb.ConfigUpdate {
66
74
Header : & cb.ChannelHeader {
@@ -83,7 +91,7 @@ type compositeTemplate struct {
83
91
templates []Template
84
92
}
85
93
86
- // NewSimpleTemplate creates a Template using the source Templates
94
+ // NewCompositeTemplate creates a Template using the source Templates
87
95
func NewCompositeTemplate (templates ... Template ) Template {
88
96
return & compositeTemplate {templates : templates }
89
97
}
@@ -119,7 +127,7 @@ func copyGroup(source *cb.ConfigGroup, target *cb.ConfigGroup) error {
119
127
return nil
120
128
}
121
129
122
- // Envelope returns the ConfigUpdateEnvelope for the given chainID
130
+ // Envelope returns a ConfigUpdateEnvelope for the given chainID
123
131
func (ct * compositeTemplate ) Envelope (chainID string ) (* cb.ConfigUpdateEnvelope , error ) {
124
132
channel := cb .NewConfigGroup ()
125
133
@@ -152,9 +160,8 @@ func (ct *compositeTemplate) Envelope(chainID string) (*cb.ConfigUpdateEnvelope,
152
160
return & cb.ConfigUpdateEnvelope {ConfigUpdate : marshaledConfig }, nil
153
161
}
154
162
155
- // NewChainCreationTemplate takes a CreationPolicy and a Template to produce a Template which outputs an appropriately
156
- // constructed list of ConfigUpdateEnvelope. Note, using this Template in
157
- // a CompositeTemplate will invalidate the CreationPolicy
163
+ // NewChainCreationTemplate takes a CreationPolicy and a Template to produce a
164
+ // Template which outputs an appropriately constructed list of ConfigUpdateEnvelopes.
158
165
func NewChainCreationTemplate (creationPolicy string , template Template ) Template {
159
166
result := cb .NewConfigGroup ()
160
167
result .Groups [configtxorderer .GroupKey ] = cb .NewConfigGroup ()
0 commit comments