@@ -160,7 +160,7 @@ func testMatcher(t *testing.T, filter [][]bloomIndexes, start, blocks uint64, in
160
160
}
161
161
}
162
162
// Track the number of retrieval requests made
163
- var requested uint32
163
+ var requested atomic. Uint32
164
164
165
165
// Start the matching session for the filter and the retriever goroutines
166
166
quit := make (chan struct {})
@@ -208,15 +208,15 @@ func testMatcher(t *testing.T, filter [][]bloomIndexes, start, blocks uint64, in
208
208
session .Close ()
209
209
close (quit )
210
210
211
- if retrievals != 0 && requested != retrievals {
212
- t .Errorf ("filter = %v blocks = %v intermittent = %v: request count mismatch, have #%v, want #%v" , filter , blocks , intermittent , requested , retrievals )
211
+ if retrievals != 0 && requested . Load () != retrievals {
212
+ t .Errorf ("filter = %v blocks = %v intermittent = %v: request count mismatch, have #%v, want #%v" , filter , blocks , intermittent , requested . Load () , retrievals )
213
213
}
214
- return requested
214
+ return requested . Load ()
215
215
}
216
216
217
217
// startRetrievers starts a batch of goroutines listening for section requests
218
218
// and serving them.
219
- func startRetrievers (session * MatcherSession , quit chan struct {}, retrievals * uint32 , batch int ) {
219
+ func startRetrievers (session * MatcherSession , quit chan struct {}, retrievals * atomic. Uint32 , batch int ) {
220
220
requests := make (chan chan * Retrieval )
221
221
222
222
for i := 0 ; i < 10 ; i ++ {
@@ -238,7 +238,7 @@ func startRetrievers(session *MatcherSession, quit chan struct{}, retrievals *ui
238
238
for i , section := range task .Sections {
239
239
if rand .Int ()% 4 != 0 { // Handle occasional missing deliveries
240
240
task .Bitsets [i ] = generateBitset (task .Bit , section )
241
- atomic . AddUint32 ( retrievals , 1 )
241
+ retrievals . Add ( 1 )
242
242
}
243
243
}
244
244
request <- task
0 commit comments