From d8800e5cdd1cec38f295473e51032667ff6d023b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 23 Nov 2022 09:34:03 +0100 Subject: [PATCH] Save gas on IsFeeEnabled (backport #2786) (#2816) improvements: save some gas in fee keeper --- CHANGELOG.md | 2 ++ modules/apps/29-fee/keeper/keeper.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c90c148495..4a4540c2d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (apps/29-fee) [\#2786](https://github.com/cosmos/ibc-go/pull/2786) Save gas by checking key existence with `KVStore`'s `Has` method. + ### Features ### Bug Fixes diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 6136ad22229..1bd7e2f1d3e 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -122,7 +122,7 @@ func (k Keeper) DeleteFeeEnabled(ctx sdk.Context, portID, channelID string) { // fee enabled flag for the given port and channel identifiers func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) - return store.Get(types.KeyFeeEnabled(portID, channelID)) != nil + return store.Has(types.KeyFeeEnabled(portID, channelID)) } // GetAllFeeEnabledChannels returns a list of all ics29 enabled channels containing portID & channelID that are stored in state