6 "google.golang.org/grpc"
8 "github.com/tendermint/abci/types"
9 cmn "github.com/tendermint/tmlibs/common"
12 type GRPCServer struct {
20 app types.ABCIApplicationServer
23 // NewGRPCServer returns a new gRPC ABCI server
24 func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) cmn.Service {
25 proto, addr := cmn.ProtocolAndAddress(protoAddr)
32 s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
36 // OnStart starts the gRPC service
37 func (s *GRPCServer) OnStart() error {
38 if err := s.BaseService.OnStart(); err != nil {
41 ln, err := net.Listen(s.proto, s.addr)
46 s.server = grpc.NewServer()
47 types.RegisterABCIApplicationServer(s.server, s.app)
48 go s.server.Serve(s.listener)
52 // OnStop stops the gRPC server
53 func (s *GRPCServer) OnStop() {
54 s.BaseService.OnStop()