Skip to content

Commit

Permalink
refactor: simplify epoch hooks (#21552)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Sep 5, 2024
1 parent 3d0fba5 commit 30688b0
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 19 deletions.
7 changes: 0 additions & 7 deletions x/epochs/types/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ type EpochHooks interface {
AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error
// new epoch is next block of epoch end block
BeforeEpochStart(ctx context.Context, epochIdentifier string, epochNumber int64) error
// Returns the name of the module implementing epoch hook.
GetModuleName() string
}

var _ EpochHooks = MultiEpochHooks{}

// combine multiple gamm hooks, all hook functions are run in array sequence.
type MultiEpochHooks []EpochHooks

// GetModuleName implements EpochHooks.
func (MultiEpochHooks) GetModuleName() string {
return ModuleName
}

func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks {
return hooks
}
Expand Down
5 changes: 0 additions & 5 deletions x/epochs/types/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ type dummyEpochHook struct {
shouldError bool
}

// GetModuleName implements types.EpochHooks.
func (*dummyEpochHook) GetModuleName() string {
return "dummy"
}

func (hook *dummyEpochHook) AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error {
if hook.shouldError {
return dummyErr
Expand Down
5 changes: 0 additions & 5 deletions x/mint/epoch_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (

var _ epochstypes.EpochHooks = AppModule{}

// GetModuleName implements types.EpochHooks.
func (am AppModule) GetModuleName() string {
return am.Name()
}

// BeforeEpochStart calls the mint function.
func (am AppModule) BeforeEpochStart(ctx context.Context, epochIdentifier string, epochNumber int64) error {
minter, err := am.keeper.Minter.Get(ctx)
Expand Down
1 change: 1 addition & 0 deletions x/mint/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ replace (
cosmossdk.io/store => ../../store
cosmossdk.io/x/bank => ../bank
cosmossdk.io/x/consensus => ../consensus
cosmossdk.io/x/epochs => ../epochs
cosmossdk.io/x/staking => ../staking
cosmossdk.io/x/tx => ../tx
)
2 changes: 0 additions & 2 deletions x/mint/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/schema v0.2.0 h1:UH5CR1DqUq8yP+5Np8PbvG4YX0zAUsTN2Qk6yThmfMk=
cosmossdk.io/schema v0.2.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 h1:GuBrfHsK3RD5vlD4DuBz3DXslR6VlnzrYmHOC3L679Q=
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337/go.mod h1:PhLn1pMBilyRC4GfRkoYhm+XVAYhF4adVrzut8AdpJI=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
Expand Down

0 comments on commit 30688b0

Please sign in to comment.