-
Notifications
You must be signed in to change notification settings - Fork 105
/
grpc_query.go
76 lines (57 loc) · 1.99 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package keeper
import (
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types"
)
var _ types.QueryServer = Keeper{} //nolint:golint
func (k Keeper) QueryNextFeeDistribution(c context.Context, //nolint:golint
req *types.QueryNextFeeDistributionEstimateRequest,
) (*types.QueryNextFeeDistributionEstimateResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
nextDist := k.GetEstimatedNextFeeDistribution(ctx)
return &types.QueryNextFeeDistributionEstimateResponse{Data: &nextDist}, nil
}
func (k Keeper) QueryParams(c context.Context, //nolint:golint
req *types.QueryParamsRequest,
) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
p := k.GetConsumerParams(ctx)
return &types.QueryParamsResponse{Params: p}, nil
}
func (k Keeper) QueryProviderInfo(c context.Context, //nolint:golint
req *types.QueryProviderInfoRequest,
) (*types.QueryProviderInfoResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
if req == nil {
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}
return k.GetProviderInfo(ctx)
}
func (k Keeper) QueryThrottleState(c context.Context,
req *types.QueryThrottleStateRequest,
) (*types.QueryThrottleStateResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
resp := types.QueryThrottleStateResponse{}
slashRecord, found := k.GetSlashRecord(ctx)
if found {
resp.SlashRecord = &slashRecord
} else {
resp.SlashRecord = nil
}
resp.PacketDataQueue = make([]ccvtypes.ConsumerPacketData, 0)
pendingPackets := k.GetAllPendingPacketsWithIdx(ctx)
for _, packet := range pendingPackets {
resp.PacketDataQueue = append(resp.PacketDataQueue, packet.ConsumerPacketData)
}
return &resp, nil
}