feat(epochs): add wrapper of epoch getter (#22068)
This commit is contained in:
@@ -68,22 +68,6 @@ The `epochs` module emits the following events:
|
||||
|
||||
Epochs keeper module provides utility functions to manage epochs.
|
||||
|
||||
``` go
|
||||
// Keeper is the interface for epochs module keeper
|
||||
type Keeper interface {
|
||||
// GetEpochInfo returns epoch info by identifier
|
||||
GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo
|
||||
// SetEpochInfo set epoch info
|
||||
SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo)
|
||||
// DeleteEpochInfo delete epoch info
|
||||
DeleteEpochInfo(ctx sdk.Context, identifier string)
|
||||
// IterateEpochInfo iterate through epochs
|
||||
IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool))
|
||||
// Get all epoch infos
|
||||
AllEpochInfos(ctx sdk.Context) []types.EpochInfo
|
||||
}
|
||||
```
|
||||
|
||||
## Hooks
|
||||
|
||||
```go
|
||||
|
||||
@@ -5,8 +5,15 @@ import (
|
||||
"fmt"
|
||||
|
||||
"cosmossdk.io/x/epochs/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// GetEpochInfo returns epoch info by identifier.
|
||||
func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, error) {
|
||||
return k.EpochInfo.Get(ctx, identifier)
|
||||
}
|
||||
|
||||
// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation,
|
||||
// or re-uses an existing identifier.
|
||||
// This method also sets the start time if left unset, and sets the epoch start height.
|
||||
|
||||
Reference in New Issue
Block a user