-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
service.go
42 lines (32 loc) · 1.13 KB
/
service.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
package node
import (
context "context"
gogogrpc "github.com/gogo/protobuf/grpc"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// RegisterNodeService registers the node gRPC service on the provided gRPC router.
func RegisterNodeService(clientCtx client.Context, server gogogrpc.Server) {
RegisterServiceServer(server, NewQueryServer(clientCtx))
}
// RegisterGRPCGatewayRoutes mounts the node gRPC service's GRPC-gateway routes
// on the given mux object.
func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) {
_ = RegisterServiceHandlerClient(context.Background(), mux, NewServiceClient(clientConn))
}
var _ ServiceServer = queryServer{}
type queryServer struct {
clientCtx client.Context
}
func NewQueryServer(clientCtx client.Context) ServiceServer {
return queryServer{
clientCtx: clientCtx,
}
}
func (s queryServer) Config(ctx context.Context, _ *ConfigRequest) (*ConfigResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
return &ConfigResponse{
MinimumGasPrice: sdkCtx.MinGasPrices().String(),
}, nil
}