Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Nov 29, 2024
1 parent 0b1f4bf commit 75842f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 3 additions & 3 deletions internal/v2/db/client/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (v2dbclient *V2Database) IncrementOverallStats(
}
// Define the work to be done in the transaction
transactionWork := func(sessCtx mongo.SessionContext) (interface{}, error) {
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, types.Active.ToString(), "v2_overall_stats")
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, types.Active.ToString(), "overall_stats")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (v2dbclient *V2Database) SubtractOverallStats(

// Define the work to be done in the transaction
transactionWork := func(sessCtx mongo.SessionContext) (interface{}, error) {
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, types.Unbonded.ToString(), "v2_overall_stats")
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, types.Unbonded.ToString(), "overall_stats")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -269,7 +269,7 @@ func (v2dbclient *V2Database) updateStakerStats(ctx context.Context, state, stak
defer session.EndSession(ctx)

transactionWork := func(sessCtx mongo.SessionContext) (interface{}, error) {
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, state, "v2_staker_stats")
err := v2dbclient.updateStatsLockByFieldName(sessCtx, stakingTxHashHex, state, "staker_stats")
if err != nil {
return nil, err
}
Expand Down
20 changes: 4 additions & 16 deletions internal/v2/queue/handler/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,11 @@ func (h *V2QueueHandler) ActiveStakingHandler(ctx context.Context, messageBody s
return types.NewError(http.StatusBadRequest, types.BadRequest, err)
}

// Check if delegation already exists
exist, delError := h.Service.IsDelegationPresent(ctx, activeStakingEvent.StakingTxHashHex)
if delError != nil {
return delError
// Perform the address lookup conversion
addressLookupErr := h.performAddressLookupConversion(ctx, activeStakingEvent.StakerBtcPkHex, types.Active)
if addressLookupErr != nil {
return addressLookupErr
}
if exist {
// Ignore the message as the delegation already exists. This is a duplicate message
log.Ctx(ctx).Debug().Str("StakingTxHashHex", activeStakingEvent.StakingTxHashHex).
Msg("delegation already exists")
return nil
}

// // Perform the address lookup conversion
// addressLookupErr := h.performAddressLookupConversion(ctx, activeStakingEvent.StakerBtcPkHex, types.Active)
// if addressLookupErr != nil {
// return addressLookupErr
// }

// Perform the stats calculation
statsErr := h.Service.ProcessStakingStatsCalculation(
Expand Down

0 comments on commit 75842f6

Please sign in to comment.