@@ -119,12 +119,12 @@ func (r *retriever) MostRecentCollectionConfigBelow(blockNum uint64, chaincodeNa
119
119
if err != nil {
120
120
return nil , err
121
121
}
122
- qe , err := r .ledgerInfoRetriever . NewQueryExecutor ( )
122
+ implicitColls , err := r .getImplicitCollection ( chaincodeName )
123
123
if err != nil {
124
124
return nil , err
125
125
}
126
- defer qe . Done ()
127
- return addImplicitCollections (compositeKV , r . ledgerID , chaincodeName , qe , r . deployedCCInfoProvider )
126
+
127
+ return constructCollectionConfigInfo (compositeKV , implicitColls )
128
128
}
129
129
130
130
// CollectionConfigAt implements function from the interface ledger.ConfigHistoryRetriever
@@ -143,12 +143,20 @@ func (r *retriever) CollectionConfigAt(blockNum uint64, chaincodeName string) (*
143
143
if err != nil {
144
144
return nil , err
145
145
}
146
+ implicitColls , err := r .getImplicitCollection (chaincodeName )
147
+ if err != nil {
148
+ return nil , err
149
+ }
150
+ return constructCollectionConfigInfo (compositeKV , implicitColls )
151
+ }
152
+
153
+ func (r * retriever ) getImplicitCollection (chaincodeName string ) ([]* common.StaticCollectionConfig , error ) {
146
154
qe , err := r .ledgerInfoRetriever .NewQueryExecutor ()
147
155
if err != nil {
148
156
return nil , err
149
157
}
150
158
defer qe .Done ()
151
- return addImplicitCollections ( compositeKV , r .ledgerID , chaincodeName , qe , r . deployedCCInfoProvider )
159
+ return r . deployedCCInfoProvider . ImplicitCollections ( r .ledgerID , chaincodeName , qe )
152
160
}
153
161
154
162
func prepareDBBatch (chaincodeCollConfigs map [string ]* common.CollectionConfigPackage , committingBlockNum uint64 ) (* batch , error ) {
@@ -170,7 +178,10 @@ func compositeKVToCollectionConfig(compositeKV *compositeKV) (*ledger.Collection
170
178
if err := proto .Unmarshal (compositeKV .value , conf ); err != nil {
171
179
return nil , errors .Wrap (err , "error unmarshalling compositeKV to collection config" )
172
180
}
173
- return & ledger.CollectionConfigInfo {CollectionConfig : conf , CommittingBlockNum : compositeKV .blockNum }, nil
181
+ return & ledger.CollectionConfigInfo {
182
+ CollectionConfig : conf ,
183
+ CommittingBlockNum : compositeKV .blockNum ,
184
+ }, nil
174
185
}
175
186
176
187
func constructCollectionConfigKey (chaincodeName string ) string {
@@ -189,17 +200,13 @@ func extractPublicUpdates(stateUpdates ledger.StateUpdates) map[string][]*kvrwse
189
200
return m
190
201
}
191
202
192
- func addImplicitCollections (
203
+ func constructCollectionConfigInfo (
193
204
compositeKV * compositeKV ,
194
- lgrID , ccName string , qe ledger.SimpleQueryExecutor ,
195
- p ledger.DeployedChaincodeInfoProvider ,
205
+ implicitColls []* common.StaticCollectionConfig ,
196
206
) (* ledger.CollectionConfigInfo , error ) {
197
207
var collConf * ledger.CollectionConfigInfo
198
208
var err error
199
- var implicitColls []* common.StaticCollectionConfig
200
- if implicitColls , err = p .ImplicitCollections (lgrID , ccName , qe ); err != nil {
201
- return nil , err
202
- }
209
+
203
210
if compositeKV == nil && len (implicitColls ) == 0 {
204
211
return nil , nil
205
212
}
0 commit comments