Skip to content

Commit

Permalink
blsagg: use defer for unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
chzyer committed Jun 21, 2024
1 parent 6ec28a8 commit 2d89859
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions services/bls_aggregation/blsagg.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,12 @@ func (a *BlsAggregatorService) InitializeNewTask(
a.logger.Debug("AggregatorService initializing new task", "taskIndex", taskIndex, "taskCreatedBlock", taskCreatedBlock, "quorumNumbers", quorumNumbers, "quorumThresholdPercentages", quorumThresholdPercentages, "timeToExpiry", timeToExpiry)

a.taskChansMutex.Lock()
signedTaskRespsC, taskExists := a.signedTaskRespsCs[taskIndex]
if !taskExists {
signedTaskRespsC = make(chan types.SignedTaskResponseDigest)
a.signedTaskRespsCs[taskIndex] = signedTaskRespsC
}
a.taskChansMutex.Unlock()
if taskExists {
defer a.taskChansMutex.Unlock()
if _, taskExists := a.signedTaskRespsCs[taskIndex]; taskExists {
return TaskAlreadyInitializedErrorFn(taskIndex)
}
signedTaskRespsC := make(chan types.SignedTaskResponseDigest)
a.signedTaskRespsCs[taskIndex] = signedTaskRespsC

go a.singleTaskAggregatorGoroutineFunc(taskIndex, taskCreatedBlock, quorumNumbers, quorumThresholdPercentages, timeToExpiry, signedTaskRespsC)
return nil
Expand Down

0 comments on commit 2d89859

Please sign in to comment.