diff --git a/core/kernel.go b/core/kernel.go index 4f3df68b9d2e60cb391e81492c4d7d1c9ef3b1a8..faab16fc51c3a3c3d810dc4b58d05f1606ee8c0e 100644 --- a/core/kernel.go +++ b/core/kernel.go @@ -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{ diff --git a/rpc/config.go b/rpc/config.go index eba0b7ed93758a45b0ae21539031dee279f579f1..796b7f656191092b95d7826b5d39834be27b24a5 100644 --- a/rpc/config.go +++ b/rpc/config.go @@ -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,