@@ -33,7 +33,7 @@ const (
33
33
34
34
// ChainCode the fields necessary to execute operation over chaincode.
35
35
type ChainCode struct {
36
- Channel * Channel
36
+ ChannelId string
37
37
Name string
38
38
Version string
39
39
Type ChainCodeType
@@ -59,7 +59,7 @@ func (c *ChainCode) toChainCodeArgs() ([][]byte) {
59
59
60
60
// InstallRequest holds fields needed to install chaincode
61
61
type InstallRequest struct {
62
- Channel * Channel
62
+ ChannelId string
63
63
ChainCodeName string
64
64
ChainCodeVersion string
65
65
ChainCodeType ChainCodeType
@@ -68,6 +68,13 @@ type InstallRequest struct {
68
68
Libraries []ChaincodeLibrary
69
69
}
70
70
71
+ type CollectionConfig struct {
72
+ Name string
73
+ RequiredPeersCount int32
74
+ MaximumPeersCount int32
75
+ Organizations []string
76
+ }
77
+
71
78
type ChaincodeLibrary struct {
72
79
Namespace string
73
80
SrcPath string
@@ -82,7 +89,7 @@ type ChainCodesResponse struct {
82
89
83
90
// createInstallProposal read chaincode from provided source and namespace, pack it and generate install proposal
84
91
// transaction. Transaction is not send from this func
85
- func createInstallProposal (identity * Identity , req * InstallRequest ) (* transactionProposal , error ) {
92
+ func createInstallProposal (identity Identity , req * InstallRequest ) (* transactionProposal , error ) {
86
93
87
94
var packageBytes []byte
88
95
var err error
@@ -109,13 +116,13 @@ func createInstallProposal(identity *Identity, req *InstallRequest) (*transactio
109
116
return nil , err
110
117
}
111
118
112
- spec , err := chainCodeInvocationSpec (& ChainCode {Type : req .ChainCodeType ,
119
+ spec , err := chainCodeInvocationSpec (ChainCode {Type : req .ChainCodeType ,
113
120
Name : LSCC ,
114
121
Args : []string {"install" },
115
122
ArgBytes : depSpec ,
116
123
})
117
124
118
- creator , err := marshalProtoIdentity (identity , req . Channel )
125
+ creator , err := marshalProtoIdentity (identity )
119
126
if err != nil {
120
127
return nil , err
121
128
}
@@ -125,7 +132,7 @@ func createInstallProposal(identity *Identity, req *InstallRequest) (*transactio
125
132
}
126
133
ccHdrExt := & peer.ChaincodeHeaderExtension {ChaincodeId : & peer.ChaincodeID {Name : LSCC }}
127
134
128
- channelHeaderBytes , err := channelHeader (common .HeaderType_ENDORSER_TRANSACTION , txId , req .Channel , 0 , ccHdrExt )
135
+ channelHeaderBytes , err := channelHeader (common .HeaderType_ENDORSER_TRANSACTION , txId , req .ChannelId , 0 , ccHdrExt )
129
136
if err != nil {
130
137
return nil , err
131
138
}
@@ -158,7 +165,7 @@ func createInstallProposal(identity *Identity, req *InstallRequest) (*transactio
158
165
159
166
// createInstantiateProposal creates instantiate proposal transaction for already installed chaincode.
160
167
// transaction is not send from this func
161
- func createInstantiateProposal (identity * Identity , req * ChainCode , operation string ) (* transactionProposal , error ) {
168
+ func createInstantiateProposal (identity Identity , req * ChainCode , operation string , collectionConfig [] byte ) (* transactionProposal , error ) {
162
169
if operation != "deploy" && operation != "upgrade" {
163
170
return nil , fmt .Errorf ("install proposall accept only 'deploy' and 'upgrade' operations" )
164
171
}
@@ -174,7 +181,7 @@ func createInstantiateProposal(identity *Identity, req *ChainCode, operation str
174
181
return nil , err
175
182
}
176
183
177
- policy , err := defaultPolicy (req . Channel .MspId )
184
+ policy , err := defaultPolicy (identity .MspId )
178
185
if err != nil {
179
186
return nil , err
180
187
}
@@ -183,18 +190,25 @@ func createInstantiateProposal(identity *Identity, req *ChainCode, operation str
183
190
return nil , err
184
191
}
185
192
186
- spec , err := chainCodeInvocationSpec (& ChainCode {
187
- Type : req .Type ,
188
- Name : LSCC ,
189
- rawArgs : [][]byte {
190
- []byte (operation ),
191
- []byte (req .Channel .ChannelName ),
192
- depSpec , marshPolicy ,
193
- []byte ("escc" ), []byte ("vscc" ),
194
- },
193
+ args := [][]byte {
194
+ []byte (operation ),
195
+ []byte (req .ChannelId ),
196
+ depSpec ,
197
+ marshPolicy ,
198
+ []byte ("escc" ),
199
+ []byte ("vscc" ),
200
+ }
201
+ if len (collectionConfig ) > 0 {
202
+ args = append (args , collectionConfig )
203
+ }
204
+
205
+ spec , err := chainCodeInvocationSpec (ChainCode {
206
+ Type : req .Type ,
207
+ Name : LSCC ,
208
+ rawArgs : args ,
195
209
})
196
210
197
- creator , err := marshalProtoIdentity (identity , req . Channel )
211
+ creator , err := marshalProtoIdentity (identity )
198
212
if err != nil {
199
213
return nil , err
200
214
}
@@ -204,7 +218,7 @@ func createInstantiateProposal(identity *Identity, req *ChainCode, operation str
204
218
}
205
219
headerExtension := & peer.ChaincodeHeaderExtension {ChaincodeId : & peer.ChaincodeID {Name : LSCC }}
206
220
207
- channelHeaderBytes , err := channelHeader (common .HeaderType_ENDORSER_TRANSACTION , txId , req .Channel , 0 , headerExtension )
221
+ channelHeaderBytes , err := channelHeader (common .HeaderType_ENDORSER_TRANSACTION , txId , req .ChannelId , 0 , headerExtension )
208
222
if err != nil {
209
223
return nil , err
210
224
}
0 commit comments