Skip to content

Commit

Permalink
do not wait forever
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazar955 committed Dec 18, 2024
1 parent b6e3b69 commit 65a25dd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ func (sew *StakingEventWatcher) activateBtcDelegation(
defer sew.latency("activateBtcDelegation")()
defer sew.inProgressTracker.RemoveDelegation(stakingTxHash)

sew.waitForRequiredDepth(ctx, stakingTxHash, &inclusionBlockHash, requiredDepth)
if err := sew.waitForRequiredDepth(ctx, stakingTxHash, &inclusionBlockHash, requiredDepth); err != nil {
sew.logger.Warnf("exceeded waiting for required depth, will try later: err %v", err)
return

Check failure on line 682 in btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go

View workflow job for this annotation

GitHub Actions / lint_test / lint

return with no blank line before (nlreturn)
}

defer sew.latency("activateDelegationRPC")()

Expand Down Expand Up @@ -724,11 +727,11 @@ func (sew *StakingEventWatcher) waitForRequiredDepth(
stakingTxHash chainhash.Hash,
inclusionBlockHash *chainhash.Hash,
requiredDepth uint32,
) {
) error {
defer sew.latency("waitForRequiredDepth")()

var depth uint32
_ = retry.Do(func() error {
return retry.Do(func() error {

Check failure on line 734 in btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go

View workflow job for this annotation

GitHub Actions / lint_test / lint

return with no blank line before (nlreturn)
var err error
depth, err = sew.babylonNodeAdapter.QueryHeaderDepth(inclusionBlockHash)
if err != nil {
Expand All @@ -749,7 +752,7 @@ func (sew *StakingEventWatcher) waitForRequiredDepth(
return nil
},
retry.Context(ctx),
retryForever,
retry.Attempts(10),
fixedDelyTypeWithJitter,
retry.MaxDelay(sew.cfg.RetrySubmitUnbondingTxInterval),
retry.MaxJitter(sew.cfg.RetryJitter),
Expand Down

0 comments on commit 65a25dd

Please sign in to comment.