Skip to content

Commit

Permalink
fix begin/end blockers
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed Jan 8, 2025
1 parent 5fc1d08 commit dde70d6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion x/alloc/abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package alloc

Check failure on line 1 in x/alloc/abci.go

View workflow job for this annotation

GitHub Actions / golangci-lint

: # github.com/public-awesome/stargaze/v15/x/alloc

Check failure on line 1 in x/alloc/abci.go

View workflow job for this annotation

GitHub Actions / golangci-lint

: # github.com/public-awesome/stargaze/v15/x/alloc

import (
"context"
"fmt"
"time"

Expand All @@ -11,7 +12,8 @@ import (
)

// BeginBlocker to distribute specific rewards on every begin block
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
func BeginBlocker(goCtx context.Context, k keeper.Keeper) {
ctx := sdk.UnwrapSDKContext(goCtx)
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
if err := k.DistributeInflation(ctx); err != nil {
panic(fmt.Sprintf("Error distribute inflation: %s", err.Error()))
Expand Down
6 changes: 4 additions & 2 deletions x/alloc/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

// this line is used by starport scaffolding # 1

"cosmossdk.io/core/appmodule"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

Expand All @@ -23,8 +24,9 @@ import (
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ appmodule.HasBeginBlocker = AppModule{}
)

// ----------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion x/mint/abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mint

import (
"context"
"time"

"github.com/cosmos/cosmos-sdk/telemetry"
Expand All @@ -10,7 +11,8 @@ import (
)

// BeginBlocker mints new tokens for the previous block.
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
func BeginBlocker(goCtx context.Context, k keeper.Keeper) {
ctx := sdk.UnwrapSDKContext(goCtx)
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)

// fetch stored minter & params
Expand Down
9 changes: 6 additions & 3 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"

"cosmossdk.io/core/appmodule"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand All @@ -21,8 +22,9 @@ import (
)

var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
_ appmodule.HasBeginBlocker = AppModule{}
)

// AppModuleBasic defines the basic application module used by the mint module.
Expand Down Expand Up @@ -145,8 +147,9 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
func (AppModule) ConsensusVersion() uint64 { return 2 }

// BeginBlock returns the begin blocker for the mint module.
func (am AppModule) BeginBlock(ctx sdk.Context) {
func (am AppModule) BeginBlock(ctx context.Context) error {
BeginBlocker(ctx, am.keeper)
return nil
}

// EndBlock returns the end blocker for the mint module. It returns no validator
Expand Down

0 comments on commit dde70d6

Please sign in to comment.