-
Notifications
You must be signed in to change notification settings - Fork 192
/
query_server.go
33 lines (26 loc) · 947 Bytes
/
query_server.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
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/lavanet/lava/x/downtime/v1"
)
var _ v1.QueryServer = queryServer{}
type queryServer struct {
k Keeper
}
func (q queryServer) QueryParams(ctx context.Context, request *v1.QueryParamsRequest) (*v1.QueryParamsResponse, error) {
params := q.k.GetParams(sdk.UnwrapSDKContext(ctx))
return &v1.QueryParamsResponse{Params: ¶ms}, nil
}
func (q queryServer) QueryDowntime(ctx context.Context, request *v1.QueryDowntimeRequest) (*v1.QueryDowntimeResponse, error) {
_ctx := sdk.UnwrapSDKContext(ctx)
epochStart, _, err := q.k.epochStorageKeeper.GetEpochStartForBlock(_ctx, request.EpochStartBlock)
if err != nil {
return nil, err
}
dt, _ := q.k.GetDowntime(sdk.UnwrapSDKContext(ctx), epochStart)
return &v1.QueryDowntimeResponse{CumulativeDowntimeDuration: dt}, nil
}
func NewQueryServer(k Keeper) v1.QueryServer {
return &queryServer{k: k}
}