From 65a25ddbe4f3c7c5777a1543b976cf5dcc49f472 Mon Sep 17 00:00:00 2001 From: Lazar Date: Wed, 18 Dec 2024 14:19:03 +0100 Subject: [PATCH] do not wait forever --- .../stakingeventwatcher/stakingeventwatcher.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go b/btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go index c406228..bb15081 100644 --- a/btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go +++ b/btcstaking-tracker/stakingeventwatcher/stakingeventwatcher.go @@ -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 + } defer sew.latency("activateDelegationRPC")() @@ -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 { var err error depth, err = sew.babylonNodeAdapter.QueryHeaderDepth(inclusionBlockHash) if err != nil { @@ -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),