Skip to content

Commit

Permalink
fix double close
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Dec 19, 2024
1 parent bc643d1 commit ae10617
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ func (sew *StakingEventWatcher) activateBtcDelegation(
requiredDepth uint32,
done chan struct{},
) {
defer close(done)
var once sync.Once
defer once.Do(func() { close(done) })
sew.metrics.NumberOfActivationInProgress.Inc()
defer sew.metrics.NumberOfActivationInProgress.Dec()

Expand Down Expand Up @@ -714,7 +715,9 @@ func (sew *StakingEventWatcher) activateBtcDelegation(

sew.metrics.ReportedActivateDelegationsCounter.Inc()

close(done)
once.Do(func() {
close(done)
})

sew.pendingTracker.RemoveDelegation(stakingTxHash)
sew.metrics.NumberOfVerifiedDelegations.Dec()
Expand Down

0 comments on commit ae10617

Please sign in to comment.