forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc_query.go
34 lines (26 loc) · 911 Bytes
/
grpc_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package keeper
import (
"context"
"errors"
"github.com/MonOsmosis/osmosis/v3/x/epochs/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ types.QueryServer = Keeper{}
// EpochInfos provide running epochInfos
func (k Keeper) EpochInfos(c context.Context, _ *types.QueryEpochsInfoRequest) (*types.QueryEpochsInfoResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
return &types.QueryEpochsInfoResponse{
Epochs: k.AllEpochInfos(ctx),
}, nil
}
// CurrentEpoch provides current epoch of specified identifier
func (k Keeper) CurrentEpoch(c context.Context, req *types.QueryCurrentEpochRequest) (*types.QueryCurrentEpochResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
info := k.GetEpochInfo(ctx, req.Identifier)
if info.Identifier != req.Identifier {
return nil, errors.New("not available identifier")
}
return &types.QueryCurrentEpochResponse{
CurrentEpoch: info.CurrentEpoch,
}, nil
}