Skip to content

Commit

Permalink
remove unbonding submitted stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Nov 7, 2024
1 parent d84ec84 commit d0b2ba5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 53 deletions.
44 changes: 0 additions & 44 deletions internal/services/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
}
16 changes: 7 additions & 9 deletions internal/types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d0b2ba5

Please sign in to comment.