-
Notifications
You must be signed in to change notification settings - Fork 55
/
grpc_query.go
37 lines (30 loc) 路 1.06 KB
/
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
35
36
37
package keeper
import (
"context"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crescent-network/crescent/v5/x/marker/types"
)
// Querier is used as Keeper will have duplicate methods if used directly,
// and gRPC names take precedence over keeper.
type Querier struct {
Keeper
}
var _ types.QueryServer = Querier{}
// Params queries the parameters of the module.
func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
var params types.Params
k.Keeper.paramSpace.GetParamSet(ctx, ¶ms)
return &types.QueryParamsResponse{Params: params}, nil
}
// LastBlockTime queries the last block time.
func (k Querier) LastBlockTime(c context.Context, _ *types.QueryLastBlockTimeRequest) (*types.QueryLastBlockTimeResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
var lastBlockTimePtr *time.Time
lastBlockTime, found := k.GetLastBlockTime(ctx)
if found {
lastBlockTimePtr = &lastBlockTime
}
return &types.QueryLastBlockTimeResponse{LastBlockTime: lastBlockTimePtr}, nil
}