Skip to content

Commit

Permalink
fix concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM committed Aug 13, 2024
1 parent a1fbf75 commit 4e7d732
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ func New(
}

func (a *Aggregator) retrieveWitnesses() {
currentWorkers := 0
for {
select {
case <-a.ctx.Done():
return
case dbBatch := <-a.witnessRetrievalChan:
currentWorkers := 0
a.activeWitnessRetrievalWorkersMutex.Lock()
currentWorkers = a.activeWitnessRetrievalWorkers
a.activeWitnessRetrievalWorkersMutex.Unlock()
Expand All @@ -212,10 +212,10 @@ func (a *Aggregator) retrieveWitnesses() {
currentWorkers = a.activeWitnessRetrievalWorkers
a.activeWitnessRetrievalWorkersMutex.Unlock()
}
go a.retrieveWitness(dbBatch)
a.activeWitnessRetrievalWorkersMutex.Lock()
a.activeWitnessRetrievalWorkers++
a.activeWitnessRetrievalWorkersMutex.Unlock()
go a.retrieveWitness(dbBatch)
}
}
}
Expand Down

0 comments on commit 4e7d732

Please sign in to comment.