forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.go
398 lines (366 loc) · 13.1 KB
/
state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
// Code generated by counterfeiter. DO NOT EDIT.
package mocks
import (
"sync"
validation "github.com/hyperledger/fabric/core/handlers/validation/api/state"
)
type State struct {
DoneStub func()
doneMutex sync.RWMutex
doneArgsForCall []struct {
}
GetPrivateDataMetadataByHashStub func(string, string, []byte) (map[string][]byte, error)
getPrivateDataMetadataByHashMutex sync.RWMutex
getPrivateDataMetadataByHashArgsForCall []struct {
arg1 string
arg2 string
arg3 []byte
}
getPrivateDataMetadataByHashReturns struct {
result1 map[string][]byte
result2 error
}
getPrivateDataMetadataByHashReturnsOnCall map[int]struct {
result1 map[string][]byte
result2 error
}
GetStateMetadataStub func(string, string) (map[string][]byte, error)
getStateMetadataMutex sync.RWMutex
getStateMetadataArgsForCall []struct {
arg1 string
arg2 string
}
getStateMetadataReturns struct {
result1 map[string][]byte
result2 error
}
getStateMetadataReturnsOnCall map[int]struct {
result1 map[string][]byte
result2 error
}
GetStateMultipleKeysStub func(string, []string) ([][]byte, error)
getStateMultipleKeysMutex sync.RWMutex
getStateMultipleKeysArgsForCall []struct {
arg1 string
arg2 []string
}
getStateMultipleKeysReturns struct {
result1 [][]byte
result2 error
}
getStateMultipleKeysReturnsOnCall map[int]struct {
result1 [][]byte
result2 error
}
GetStateRangeScanIteratorStub func(string, string, string) (validation.ResultsIterator, error)
getStateRangeScanIteratorMutex sync.RWMutex
getStateRangeScanIteratorArgsForCall []struct {
arg1 string
arg2 string
arg3 string
}
getStateRangeScanIteratorReturns struct {
result1 validation.ResultsIterator
result2 error
}
getStateRangeScanIteratorReturnsOnCall map[int]struct {
result1 validation.ResultsIterator
result2 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *State) Done() {
fake.doneMutex.Lock()
fake.doneArgsForCall = append(fake.doneArgsForCall, struct {
}{})
fake.recordInvocation("Done", []interface{}{})
fake.doneMutex.Unlock()
if fake.DoneStub != nil {
fake.DoneStub()
}
}
func (fake *State) DoneCallCount() int {
fake.doneMutex.RLock()
defer fake.doneMutex.RUnlock()
return len(fake.doneArgsForCall)
}
func (fake *State) DoneCalls(stub func()) {
fake.doneMutex.Lock()
defer fake.doneMutex.Unlock()
fake.DoneStub = stub
}
func (fake *State) GetPrivateDataMetadataByHash(arg1 string, arg2 string, arg3 []byte) (map[string][]byte, error) {
var arg3Copy []byte
if arg3 != nil {
arg3Copy = make([]byte, len(arg3))
copy(arg3Copy, arg3)
}
fake.getPrivateDataMetadataByHashMutex.Lock()
ret, specificReturn := fake.getPrivateDataMetadataByHashReturnsOnCall[len(fake.getPrivateDataMetadataByHashArgsForCall)]
fake.getPrivateDataMetadataByHashArgsForCall = append(fake.getPrivateDataMetadataByHashArgsForCall, struct {
arg1 string
arg2 string
arg3 []byte
}{arg1, arg2, arg3Copy})
fake.recordInvocation("GetPrivateDataMetadataByHash", []interface{}{arg1, arg2, arg3Copy})
fake.getPrivateDataMetadataByHashMutex.Unlock()
if fake.GetPrivateDataMetadataByHashStub != nil {
return fake.GetPrivateDataMetadataByHashStub(arg1, arg2, arg3)
}
if specificReturn {
return ret.result1, ret.result2
}
fakeReturns := fake.getPrivateDataMetadataByHashReturns
return fakeReturns.result1, fakeReturns.result2
}
func (fake *State) GetPrivateDataMetadataByHashCallCount() int {
fake.getPrivateDataMetadataByHashMutex.RLock()
defer fake.getPrivateDataMetadataByHashMutex.RUnlock()
return len(fake.getPrivateDataMetadataByHashArgsForCall)
}
func (fake *State) GetPrivateDataMetadataByHashCalls(stub func(string, string, []byte) (map[string][]byte, error)) {
fake.getPrivateDataMetadataByHashMutex.Lock()
defer fake.getPrivateDataMetadataByHashMutex.Unlock()
fake.GetPrivateDataMetadataByHashStub = stub
}
func (fake *State) GetPrivateDataMetadataByHashArgsForCall(i int) (string, string, []byte) {
fake.getPrivateDataMetadataByHashMutex.RLock()
defer fake.getPrivateDataMetadataByHashMutex.RUnlock()
argsForCall := fake.getPrivateDataMetadataByHashArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
}
func (fake *State) GetPrivateDataMetadataByHashReturns(result1 map[string][]byte, result2 error) {
fake.getPrivateDataMetadataByHashMutex.Lock()
defer fake.getPrivateDataMetadataByHashMutex.Unlock()
fake.GetPrivateDataMetadataByHashStub = nil
fake.getPrivateDataMetadataByHashReturns = struct {
result1 map[string][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetPrivateDataMetadataByHashReturnsOnCall(i int, result1 map[string][]byte, result2 error) {
fake.getPrivateDataMetadataByHashMutex.Lock()
defer fake.getPrivateDataMetadataByHashMutex.Unlock()
fake.GetPrivateDataMetadataByHashStub = nil
if fake.getPrivateDataMetadataByHashReturnsOnCall == nil {
fake.getPrivateDataMetadataByHashReturnsOnCall = make(map[int]struct {
result1 map[string][]byte
result2 error
})
}
fake.getPrivateDataMetadataByHashReturnsOnCall[i] = struct {
result1 map[string][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetStateMetadata(arg1 string, arg2 string) (map[string][]byte, error) {
fake.getStateMetadataMutex.Lock()
ret, specificReturn := fake.getStateMetadataReturnsOnCall[len(fake.getStateMetadataArgsForCall)]
fake.getStateMetadataArgsForCall = append(fake.getStateMetadataArgsForCall, struct {
arg1 string
arg2 string
}{arg1, arg2})
fake.recordInvocation("GetStateMetadata", []interface{}{arg1, arg2})
fake.getStateMetadataMutex.Unlock()
if fake.GetStateMetadataStub != nil {
return fake.GetStateMetadataStub(arg1, arg2)
}
if specificReturn {
return ret.result1, ret.result2
}
fakeReturns := fake.getStateMetadataReturns
return fakeReturns.result1, fakeReturns.result2
}
func (fake *State) GetStateMetadataCallCount() int {
fake.getStateMetadataMutex.RLock()
defer fake.getStateMetadataMutex.RUnlock()
return len(fake.getStateMetadataArgsForCall)
}
func (fake *State) GetStateMetadataCalls(stub func(string, string) (map[string][]byte, error)) {
fake.getStateMetadataMutex.Lock()
defer fake.getStateMetadataMutex.Unlock()
fake.GetStateMetadataStub = stub
}
func (fake *State) GetStateMetadataArgsForCall(i int) (string, string) {
fake.getStateMetadataMutex.RLock()
defer fake.getStateMetadataMutex.RUnlock()
argsForCall := fake.getStateMetadataArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *State) GetStateMetadataReturns(result1 map[string][]byte, result2 error) {
fake.getStateMetadataMutex.Lock()
defer fake.getStateMetadataMutex.Unlock()
fake.GetStateMetadataStub = nil
fake.getStateMetadataReturns = struct {
result1 map[string][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetStateMetadataReturnsOnCall(i int, result1 map[string][]byte, result2 error) {
fake.getStateMetadataMutex.Lock()
defer fake.getStateMetadataMutex.Unlock()
fake.GetStateMetadataStub = nil
if fake.getStateMetadataReturnsOnCall == nil {
fake.getStateMetadataReturnsOnCall = make(map[int]struct {
result1 map[string][]byte
result2 error
})
}
fake.getStateMetadataReturnsOnCall[i] = struct {
result1 map[string][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetStateMultipleKeys(arg1 string, arg2 []string) ([][]byte, error) {
var arg2Copy []string
if arg2 != nil {
arg2Copy = make([]string, len(arg2))
copy(arg2Copy, arg2)
}
fake.getStateMultipleKeysMutex.Lock()
ret, specificReturn := fake.getStateMultipleKeysReturnsOnCall[len(fake.getStateMultipleKeysArgsForCall)]
fake.getStateMultipleKeysArgsForCall = append(fake.getStateMultipleKeysArgsForCall, struct {
arg1 string
arg2 []string
}{arg1, arg2Copy})
fake.recordInvocation("GetStateMultipleKeys", []interface{}{arg1, arg2Copy})
fake.getStateMultipleKeysMutex.Unlock()
if fake.GetStateMultipleKeysStub != nil {
return fake.GetStateMultipleKeysStub(arg1, arg2)
}
if specificReturn {
return ret.result1, ret.result2
}
fakeReturns := fake.getStateMultipleKeysReturns
return fakeReturns.result1, fakeReturns.result2
}
func (fake *State) GetStateMultipleKeysCallCount() int {
fake.getStateMultipleKeysMutex.RLock()
defer fake.getStateMultipleKeysMutex.RUnlock()
return len(fake.getStateMultipleKeysArgsForCall)
}
func (fake *State) GetStateMultipleKeysCalls(stub func(string, []string) ([][]byte, error)) {
fake.getStateMultipleKeysMutex.Lock()
defer fake.getStateMultipleKeysMutex.Unlock()
fake.GetStateMultipleKeysStub = stub
}
func (fake *State) GetStateMultipleKeysArgsForCall(i int) (string, []string) {
fake.getStateMultipleKeysMutex.RLock()
defer fake.getStateMultipleKeysMutex.RUnlock()
argsForCall := fake.getStateMultipleKeysArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2
}
func (fake *State) GetStateMultipleKeysReturns(result1 [][]byte, result2 error) {
fake.getStateMultipleKeysMutex.Lock()
defer fake.getStateMultipleKeysMutex.Unlock()
fake.GetStateMultipleKeysStub = nil
fake.getStateMultipleKeysReturns = struct {
result1 [][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetStateMultipleKeysReturnsOnCall(i int, result1 [][]byte, result2 error) {
fake.getStateMultipleKeysMutex.Lock()
defer fake.getStateMultipleKeysMutex.Unlock()
fake.GetStateMultipleKeysStub = nil
if fake.getStateMultipleKeysReturnsOnCall == nil {
fake.getStateMultipleKeysReturnsOnCall = make(map[int]struct {
result1 [][]byte
result2 error
})
}
fake.getStateMultipleKeysReturnsOnCall[i] = struct {
result1 [][]byte
result2 error
}{result1, result2}
}
func (fake *State) GetStateRangeScanIterator(arg1 string, arg2 string, arg3 string) (validation.ResultsIterator, error) {
fake.getStateRangeScanIteratorMutex.Lock()
ret, specificReturn := fake.getStateRangeScanIteratorReturnsOnCall[len(fake.getStateRangeScanIteratorArgsForCall)]
fake.getStateRangeScanIteratorArgsForCall = append(fake.getStateRangeScanIteratorArgsForCall, struct {
arg1 string
arg2 string
arg3 string
}{arg1, arg2, arg3})
fake.recordInvocation("GetStateRangeScanIterator", []interface{}{arg1, arg2, arg3})
fake.getStateRangeScanIteratorMutex.Unlock()
if fake.GetStateRangeScanIteratorStub != nil {
return fake.GetStateRangeScanIteratorStub(arg1, arg2, arg3)
}
if specificReturn {
return ret.result1, ret.result2
}
fakeReturns := fake.getStateRangeScanIteratorReturns
return fakeReturns.result1, fakeReturns.result2
}
func (fake *State) GetStateRangeScanIteratorCallCount() int {
fake.getStateRangeScanIteratorMutex.RLock()
defer fake.getStateRangeScanIteratorMutex.RUnlock()
return len(fake.getStateRangeScanIteratorArgsForCall)
}
func (fake *State) GetStateRangeScanIteratorCalls(stub func(string, string, string) (validation.ResultsIterator, error)) {
fake.getStateRangeScanIteratorMutex.Lock()
defer fake.getStateRangeScanIteratorMutex.Unlock()
fake.GetStateRangeScanIteratorStub = stub
}
func (fake *State) GetStateRangeScanIteratorArgsForCall(i int) (string, string, string) {
fake.getStateRangeScanIteratorMutex.RLock()
defer fake.getStateRangeScanIteratorMutex.RUnlock()
argsForCall := fake.getStateRangeScanIteratorArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
}
func (fake *State) GetStateRangeScanIteratorReturns(result1 validation.ResultsIterator, result2 error) {
fake.getStateRangeScanIteratorMutex.Lock()
defer fake.getStateRangeScanIteratorMutex.Unlock()
fake.GetStateRangeScanIteratorStub = nil
fake.getStateRangeScanIteratorReturns = struct {
result1 validation.ResultsIterator
result2 error
}{result1, result2}
}
func (fake *State) GetStateRangeScanIteratorReturnsOnCall(i int, result1 validation.ResultsIterator, result2 error) {
fake.getStateRangeScanIteratorMutex.Lock()
defer fake.getStateRangeScanIteratorMutex.Unlock()
fake.GetStateRangeScanIteratorStub = nil
if fake.getStateRangeScanIteratorReturnsOnCall == nil {
fake.getStateRangeScanIteratorReturnsOnCall = make(map[int]struct {
result1 validation.ResultsIterator
result2 error
})
}
fake.getStateRangeScanIteratorReturnsOnCall[i] = struct {
result1 validation.ResultsIterator
result2 error
}{result1, result2}
}
func (fake *State) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.doneMutex.RLock()
defer fake.doneMutex.RUnlock()
fake.getPrivateDataMetadataByHashMutex.RLock()
defer fake.getPrivateDataMetadataByHashMutex.RUnlock()
fake.getStateMetadataMutex.RLock()
defer fake.getStateMetadataMutex.RUnlock()
fake.getStateMultipleKeysMutex.RLock()
defer fake.getStateMultipleKeysMutex.RUnlock()
fake.getStateRangeScanIteratorMutex.RLock()
defer fake.getStateRangeScanIteratorMutex.RUnlock()
copiedInvocations := map[string][][]interface{}{}
for key, value := range fake.invocations {
copiedInvocations[key] = value
}
return copiedInvocations
}
func (fake *State) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}