From 03725d07af5ec0a8014302ff1f3e959e946b562d Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Sat, 24 Feb 2024 10:55:38 -0600 Subject: [PATCH] guard clauses --- x/manifest/abci.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/x/manifest/abci.go b/x/manifest/abci.go index 017f893..c1f5377 100644 --- a/x/manifest/abci.go +++ b/x/manifest/abci.go @@ -23,22 +23,30 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper, mk mintkeeper.Keeper, bk return err } + // If there is no one to pay out, skip + if len(params.StakeHolders) == 0 { + return nil + } + + // Calculate the per block inflation rewards to pay out in coins mintedCoin := k.BlockRewardsProvision(ctx, params.Inflation.MintDenom) mintedCoins := sdk.NewCoins(mintedCoin) + // If no inflation payout this block, skip + if mintedCoin.IsZero() { + return nil + } + + // mint the tokens to the network if err := mk.MintCoins(ctx, mintedCoins); err != nil { return err } + // Payout all the stakeholders with their respective share of the minted coins if err := k.PayoutStakeholders(ctx, mintedCoin); err != nil { return err } - // send the minted coins to the fee collector account - // if err := mk.AddCollectedFees(ctx, mintedCoins); err != nil { - // return err - // } - if mintedCoin.Amount.IsInt64() { defer telemetry.ModuleSetGauge(minttypes.ModuleName, float32(mintedCoin.Amount.Int64()), "minted_tokens") }