From dcd6733015033791f1af26e7470a3a4479086a4b Mon Sep 17 00:00:00 2001 From: avery <> Date: Wed, 20 Nov 2024 08:31:40 +0100 Subject: [PATCH] refactor --- modules/htlc/abci.go | 8 ++++++-- modules/htlc/module.go | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/htlc/abci.go b/modules/htlc/abci.go index 8abd819a..77004e30 100644 --- a/modules/htlc/abci.go +++ b/modules/htlc/abci.go @@ -12,7 +12,7 @@ import ( ) // BeginBlocker handles block beginning logic for HTLC -func BeginBlocker(c context.Context, k keeper.Keeper) { +func BeginBlocker(c context.Context, k keeper.Keeper) error { ctx := sdk.UnwrapSDKContext(c) ctx = ctx.WithLogger(ctx.Logger().With("handler", "beginBlock").With("module", "irismod/htlc")) @@ -21,7 +21,9 @@ func BeginBlocker(c context.Context, k keeper.Keeper) { ctx, currentBlockHeight, func(id tmbytes.HexBytes, h types.HTLC) (stop bool) { // refund HTLC - _ = k.RefundHTLC(ctx, h, id) + if err := k.RefundHTLC(ctx, h, id); err != nil { + return err + } // delete from the expiration queue k.DeleteHTLCFromExpiredQueue(ctx, currentBlockHeight, id) @@ -39,4 +41,6 @@ func BeginBlocker(c context.Context, k keeper.Keeper) { ) k.UpdateTimeBasedSupplyLimits(ctx) + + return nil } diff --git a/modules/htlc/module.go b/modules/htlc/module.go index a859c99b..79672e52 100644 --- a/modules/htlc/module.go +++ b/modules/htlc/module.go @@ -158,8 +158,7 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // BeginBlock performs a no-op. func (am AppModule) BeginBlock(ctx context.Context) error { - BeginBlocker(ctx, am.keeper) - return nil + return BeginBlocker(ctx, am.keeper) } // EndBlock returns the end blocker for the HTLC module. It returns no validator updates.