@@ -160,7 +160,7 @@ func testMatcher(t *testing.T, filter [][]bloomIndexes, start, blocks uint64, in
160160 }
161161 }
162162 // Track the number of retrieval requests made
163- var requested uint32
163+ var requested atomic. Uint32
164164
165165 // Start the matching session for the filter and the retriever goroutines
166166 quit := make (chan struct {})
@@ -208,15 +208,15 @@ func testMatcher(t *testing.T, filter [][]bloomIndexes, start, blocks uint64, in
208208 session .Close ()
209209 close (quit )
210210
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 )
213213 }
214- return requested
214+ return requested . Load ()
215215}
216216
217217// startRetrievers starts a batch of goroutines listening for section requests
218218// 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 ) {
220220 requests := make (chan chan * Retrieval )
221221
222222 for i := 0 ; i < 10 ; i ++ {
@@ -238,7 +238,7 @@ func startRetrievers(session *MatcherSession, quit chan struct{}, retrievals *ui
238238 for i , section := range task .Sections {
239239 if rand .Int ()% 4 != 0 { // Handle occasional missing deliveries
240240 task .Bitsets [i ] = generateBitset (task .Bit , section )
241- atomic . AddUint32 ( retrievals , 1 )
241+ retrievals . Add ( 1 )
242242 }
243243 }
244244 request <- task
0 commit comments