Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowman authored Jun 12, 2023
1 parent 729e5bf commit f69e7b9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions x/interchainstaking/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,15 @@ func (k *Keeper) MakePerformanceDelegation(ctx sdk.Context, zone *types.Zone, va
func (k *Keeper) FlushOutstandingDelegations(ctx sdk.Context, zone *types.Zone, delAddrBalance sdk.Coin) error {
var pendingAmount sdk.Coins
exclusionTime := ctx.BlockTime().AddDate(0, 0, -1)
var coinsToFlush sdk.Coins
k.IterateZoneReceipts(ctx, zone, func(_ int64, receiptInfo types.Receipt) (stop bool) {
if (receiptInfo.FirstSeen.After(exclusionTime) || receiptInfo.FirstSeen.Equal(exclusionTime)) && receiptInfo.Completed == nil {
pendingAmount = pendingAmount.Add(receiptInfo.Amount...)
}
return false
})

var hasNeg bool

coinsToFlush, hasNeg = sdk.NewCoins(delAddrBalance).SafeSub(pendingAmount...)
coinsToFlush, hasNeg := sdk.NewCoins(delAddrBalance).SafeSub(pendingAmount...)
if hasNeg || coinsToFlush.IsZero() {
k.Logger(ctx).Debug("delegate account balance negative, setting outdated reciepts")
k.SetReceiptsCompleted(ctx, zone, exclusionTime, ctx.BlockTime())
Expand Down

0 comments on commit f69e7b9

Please sign in to comment.