Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add logs to refund tokens #1001

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions plugins/tokens/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,33 @@ func EndBlocker(ctx sdk.Context, timelockKeeper timelock.Keeper, swapKeeper swap
iterator := timelockKeeper.GetTimeLockRecordIterator(ctx)
defer iterator.Close()
i := 0
failedCount := 0
for ; iterator.Valid(); iterator.Next() {
if i >= MaxUnlockItems {
break
}
addr, id, err := timelock.ParseKeyRecord(iterator.Key())
if err != nil {
logger.Error("failed to parse timelock record", "error", err)
failedCount++
continue
}
err = timelockKeeper.TimeUnlock(ctx, addr, id, true)
if err != nil {
logger.Error("failed to unlock the time locks", "error", err)
failedCount++
continue
}
logger.Info("succeed to unlock the time locks", "addr", addr, "id", id)
i++
if i >= MaxUnlockItems {
break
}
}
logger.Info("unlock the time locks done", "blockHeight", ctx.BlockHeight(), "succeed", i, "failed", failedCount)

swapIterator := swapKeeper.GetSwapIterator(ctx)
defer swapIterator.Close()
i = 0
failedCount = 0
for ; swapIterator.Valid(); swapIterator.Next() {
if i >= MaxUnlockItems {
break
}
var automaticSwap swap.AtomicSwap
swapKeeper.CDC().MustUnmarshalBinaryBare(swapIterator.Value(), &automaticSwap)
swapID := swapIterator.Key()[len(swap.HashKey):]
Expand All @@ -106,12 +108,17 @@ func EndBlocker(ctx sdk.Context, timelockKeeper timelock.Keeper, swapKeeper swap
})
if !result.IsOK() {
logger.Error("failed to refund swap", "swapId", swapID, "result", fmt.Sprintf("%+v", result))
failedCount++
continue
}

logger.Info("succeed to refund swap", "swapId", swapID, "swap", fmt.Sprintf("%+v", swapItem))
i++
if i >= MaxUnlockItems {
break
}
}
logger.Info("refund the swaps done", "blockHeight", ctx.BlockHeight(), "succeed", i, "failed", failedCount)
}

// EndBreatheBlock processes the breathe block lifecycle event.
Expand Down