/
grpc_query_all_timers.go
39 lines (33 loc) · 1.26 KB
/
grpc_query_all_timers.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
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/x/timerstore/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k *Keeper) AllTimers(goCtx context.Context, req *types.QueryAllTimersRequest) (*types.QueryAllTimersResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
for _, store := range k.timerStoresBegin {
if store.GetStoreKey().Name() == req.StoreKey && store.GetStorePrefix() == req.Prefix {
return &types.QueryAllTimersResponse{
BlockTimeTimers: store.DumpAllTimers(ctx, types.BlockTime),
BlockHeightTimers: store.DumpAllTimers(ctx, types.BlockHeight),
Tick: types.BeginBlock,
}, nil
}
}
for _, store := range k.timerStoresEnd {
if store.GetStoreKey().Name() == req.StoreKey && store.GetStorePrefix() == req.Prefix {
return &types.QueryAllTimersResponse{
BlockTimeTimers: store.DumpAllTimers(ctx, types.BlockTime),
BlockHeightTimers: store.DumpAllTimers(ctx, types.BlockHeight),
Tick: types.EndBlock,
}, nil
}
}
return nil, status.Error(codes.InvalidArgument, "the provided combination of store key and prefix was not found")
}