-
Notifications
You must be signed in to change notification settings - Fork 199
/
grpc_query_entry.go
40 lines (33 loc) · 993 Bytes
/
grpc_query_entry.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
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/x/fixationstore/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k *Keeper) Entry(goCtx context.Context, req *types.QueryEntryRequest) (res *types.QueryEntryResponse, err error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
var entry types.Entry
for _, store := range k.fixationsStores {
if store.GetStoreKey().Name() == req.StoreKey && store.GetStorePrefix() == req.Prefix {
entry, err = store.FindRawEntry(ctx, req.Key, req.Block)
if err != nil {
return nil, err
}
entry.Index = req.Key // desanitize index so it will be printable
break
}
}
if req.HideData {
entry.Data = nil
}
var stringData string
if req.StringData {
stringData = string(entry.Data)
}
return &types.QueryEntryResponse{Entry: &entry, StringData: stringData}, nil
}