From 934d898d48a94dfe51256db038029c22a0197629 Mon Sep 17 00:00:00 2001 From: Alexgao001 Date: Fri, 1 Dec 2023 17:59:12 +0800 Subject: [PATCH] simplify if else statement --- x/virtualgroup/keeper/keeper.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/x/virtualgroup/keeper/keeper.go b/x/virtualgroup/keeper/keeper.go index cccc0ea63..01cd8c85d 100644 --- a/x/virtualgroup/keeper/keeper.go +++ b/x/virtualgroup/keeper/keeper.go @@ -5,14 +5,13 @@ import ( "fmt" math2 "math" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "cosmossdk.io/math" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/bnb-chain/greenfield/internal/sequence" sptypes "github.com/bnb-chain/greenfield/x/sp/types" @@ -164,20 +163,15 @@ func (k Keeper) DeleteGVG(ctx sdk.Context, primarySp *sptypes.StorageProvider, g return err } - if len(gvgFamily.GlobalVirtualGroupIds) == 0 && k.paymentKeeper.IsEmptyNetFlow(ctx, sdk.MustAccAddressFromHex(gvgFamily.VirtualPaymentAddress)) { - // after Eddystone, the virtual group family can be empty. - if !ctx.IsUpgraded(upgradetypes.Eddystone) { - store.Delete(types.GetGVGFamilyKey(gvg.FamilyId)) - if err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteGlobalVirtualGroupFamily{ - Id: gvgFamily.Id, - PrimarySpId: gvgFamily.PrimarySpId, - }); err != nil { - return err - } - } else { - if err := k.SetGVGFamilyAndEmitUpdateEvent(ctx, gvgFamily); err != nil { - return err - } + if len(gvgFamily.GlobalVirtualGroupIds) == 0 && + k.paymentKeeper.IsEmptyNetFlow(ctx, sdk.MustAccAddressFromHex(gvgFamily.VirtualPaymentAddress)) && + !ctx.IsUpgraded(upgradetypes.Eddystone) { + store.Delete(types.GetGVGFamilyKey(gvg.FamilyId)) + if err := ctx.EventManager().EmitTypedEvents(&types.EventDeleteGlobalVirtualGroupFamily{ + Id: gvgFamily.Id, + PrimarySpId: gvgFamily.PrimarySpId, + }); err != nil { + return err } } else { if err := k.SetGVGFamilyAndEmitUpdateEvent(ctx, gvgFamily); err != nil {