From d0b2ba59b3745667929a1b0fe7b8fbd1ac5065dc Mon Sep 17 00:00:00 2001 From: Gurjot Date: Thu, 7 Nov 2024 15:42:43 +0700 Subject: [PATCH] remove unbonding submitted stuff --- internal/services/delegation.go | 44 --------------------------------- internal/types/state.go | 16 ++++++------ 2 files changed, 7 insertions(+), 53 deletions(-) diff --git a/internal/services/delegation.go b/internal/services/delegation.go index 32813c1..b9affb3 100644 --- a/internal/services/delegation.go +++ b/internal/services/delegation.go @@ -12,7 +12,6 @@ import ( "github.com/babylonlabs-io/babylon-staking-indexer/internal/utils" bbntypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" abcitypes "github.com/cometbft/cometbft/abci/types" - "github.com/lightningnetwork/lnd/chainntnfs" "github.com/rs/zerolog/log" ) @@ -504,46 +503,3 @@ func (s *Service) validateBTCDelegationExpiredEvent(ctx context.Context, event * return true, nil } - -func (s *Service) watchForBTCConfirmation(confEvent *chainntnfs.ConfirmationEvent, stakingTxHashHex string) { - defer s.wg.Done() - - ctx, cancel := s.quitContext() - defer cancel() - - select { - case _, ok := <-confEvent.Confirmed: - if !ok { - log.Error().Msgf("Confirmation channel closed for tx: %s", stakingTxHashHex) - return - } - - log.Debug(). - Str("stakingTxHash", stakingTxHashHex). - Msg("Received confirmation for staking transaction") - - delegation, dbErr := s.db.GetBTCDelegationByStakingTxHash(ctx, stakingTxHashHex) - if dbErr != nil { - log.Error().Err(dbErr).Msg("Error getting BTC delegation") - return - } - - // Check if the current state is qualified for the transition - if !utils.Contains(types.QualifiedStatesForPendingBTCConfirmation(), delegation.State) { - log.Debug(). - Str("stakingTxHashHex", stakingTxHashHex). - Str("currentState", delegation.State.String()). - Msg("Ignoring watchForBTCConfirmation because current state is not qualified for transition") - return - } - - // Update delegation state in database - if err := s.db.UpdateBTCDelegationState(ctx, stakingTxHashHex, types.StatePendingBTCConfirmation); err != nil { - log.Error().Err(err).Msg("Error updating BTC delegation state") - return - } - case <-ctx.Done(): - log.Info().Msgf("Context cancelled for tx: %s", stakingTxHashHex) - return - } -} diff --git a/internal/types/state.go b/internal/types/state.go index ea84869..171d63c 100644 --- a/internal/types/state.go +++ b/internal/types/state.go @@ -6,15 +6,13 @@ import bbntypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" type DelegationState string const ( - StatePending DelegationState = "PENDING" - StatePendingBTCConfirmation DelegationState = "PENDING_BTC_CONFIRMATION" - StateVerified DelegationState = "VERIFIED" - StateActive DelegationState = "ACTIVE" - StateUnbondingSubmitted DelegationState = "UNBONDING_SUBMITTED" - StateUnbonding DelegationState = "UNBONDING" - StateWithdrawable DelegationState = "WITHDRAWABLE" - StateWithdrawn DelegationState = "WITHDRAWN" - StateSlashed DelegationState = "SLASHED" + StatePending DelegationState = "PENDING" + StateVerified DelegationState = "VERIFIED" + StateActive DelegationState = "ACTIVE" + StateUnbonding DelegationState = "UNBONDING" + StateWithdrawable DelegationState = "WITHDRAWABLE" + StateWithdrawn DelegationState = "WITHDRAWN" + StateSlashed DelegationState = "SLASHED" ) func (s DelegationState) String() string {