Skip to content
Snippets Groups Projects
Commit f5600225 authored by Sean Young's avatar Sean Young
Browse files

Add config to create generic grpc server


This is so we can add a grpc keys server in a later commit

Signed-off-by: default avatarSean Young <sean.young@monax.io>
parent a722ba5e
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ package core
import (
"context"
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"os"
......@@ -44,6 +45,7 @@ import (
tm_config "github.com/tendermint/tendermint/config"
tm_types "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tmlibs/db"
"google.golang.org/grpc"
)
const (
......@@ -199,6 +201,22 @@ func NewKernel(ctx context.Context, keyClient keys.KeyClient, privValidator tm_t
return serveProcess, nil
},
},
{
Name: "grpc service",
Disabled: rpcConfig.GRPC.Disabled,
Launch: func() (process.Process, error) {
listen, err := net.Listen("tcp", rpcConfig.GRPC.ListenAddress)
if err != nil {
return nil, err
}
grpcServer := grpc.NewServer()
go grpcServer.Serve(listen)
return process.FromListeners(listen), nil
},
},
}
return &Kernel{
......
......@@ -6,6 +6,7 @@ type RPCConfig struct {
V0 *V0Config `json:",omitempty" toml:",omitempty"`
TM *TMConfig `json:",omitempty" toml:",omitempty"`
Profiler *ProfilerConfig `json:",omitempty" toml:",omitempty"`
GRPC *GRPCConfig `json:",omitempty" toml:",omitempty"`
}
type TMConfig struct {
......@@ -23,13 +24,20 @@ type ProfilerConfig struct {
ListenAddress string
}
type GRPCConfig struct {
Disabled bool
ListenAddress string
}
func DefaultRPCConfig() *RPCConfig {
return &RPCConfig{
TM: DefaultTMConfig(),
V0: DefaultV0Config(),
Profiler: DefaultProfilerConfig(),
GRPC: DefaultGRPCConfig(),
}
}
func DefaultV0Config() *V0Config {
return &V0Config{
Server: server.DefaultServerConfig(),
......@@ -42,6 +50,12 @@ func DefaultTMConfig() *TMConfig {
}
}
func DefaultGRPCConfig() *GRPCConfig {
return &GRPCConfig{
ListenAddress: "localhost:46659",
}
}
func DefaultProfilerConfig() *ProfilerConfig {
return &ProfilerConfig{
Disabled: true,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment