@@ -159,6 +159,8 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
159
159
return nil , errors .WrapErrorWithStatus (err , "failed to unmarshal asset from ledger" , 500 )
160
160
}
161
161
162
+ keysCheckedInScope := make ([]string , 0 )
163
+
162
164
for k , v := range response {
163
165
switch prop := v .(type ) {
164
166
case map [string ]interface {}:
@@ -167,17 +169,26 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
167
169
return nil , errors .WrapErrorWithStatus (err , "failed to resolve asset references" , 500 )
168
170
}
169
171
172
+ keyIsFetchedInScope := false
173
+ for _ , key := range keysCheckedInScope {
174
+ if key == propKey .Key () {
175
+ keyIsFetchedInScope = true
176
+ break
177
+ }
178
+ }
179
+
170
180
keyIsFetched := false
171
181
for _ , key := range keysChecked {
172
182
if key == propKey .Key () {
173
183
keyIsFetched = true
174
184
break
175
185
}
176
186
}
177
- if keyIsFetched {
187
+ if keyIsFetched && ! keyIsFetchedInScope {
178
188
continue
179
189
}
180
190
keysChecked = append (keysChecked , propKey .Key ())
191
+ keysCheckedInScope = append (keysCheckedInScope , propKey .Key ())
181
192
182
193
var subAsset map [string ]interface {}
183
194
if propKey .IsPrivate () {
@@ -199,17 +210,26 @@ func getRecursive(stub *sw.StubWrapper, pvtCollection, key string, keysChecked [
199
210
return nil , errors .WrapErrorWithStatus (err , "failed to resolve asset references" , 500 )
200
211
}
201
212
213
+ keyIsFetchedInScope := false
214
+ for _ , key := range keysCheckedInScope {
215
+ if key == elemKey .Key () {
216
+ keyIsFetchedInScope = true
217
+ break
218
+ }
219
+ }
220
+
202
221
keyIsFetched := false
203
222
for _ , key := range keysChecked {
204
223
if key == elemKey .Key () {
205
224
keyIsFetched = true
206
225
break
207
226
}
208
227
}
209
- if keyIsFetched {
228
+ if keyIsFetched && ! keyIsFetchedInScope {
210
229
continue
211
230
}
212
231
keysChecked = append (keysChecked , elemKey .Key ())
232
+ keysCheckedInScope = append (keysCheckedInScope , elemKey .Key ())
213
233
214
234
var subAsset map [string ]interface {}
215
235
if elemKey .IsPrivate () {
0 commit comments