From 795877262ca625bbfe3f02e80d045c5aa673faf1 Mon Sep 17 00:00:00 2001 From: Lukasz Cwik Date: Wed, 6 Dec 2023 10:47:51 -0800 Subject: [PATCH] [CLOB-930] Add support for domain sockets for gRPC server and gRPC. ctx.Done() support was added in 0.50 with https://github.com/cosmos/cosmos-sdk/pull/15041 server start up time was removed in 0.50 with https://github.com/cosmos/cosmos-sdk/pull/15041 --- server/grpc/server.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/grpc/server.go b/server/grpc/server.go index 51bcf3f445b9..c39d59b09fea 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net" + "strings" "google.golang.org/grpc" @@ -74,7 +75,17 @@ func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.G // Otherwise, an error is returned. The caller is expected to provide a Context // that is properly canceled or closed to indicate the server should be stopped. func StartGRPCServer(ctx context.Context, logger log.Logger, cfg config.GRPCConfig, grpcSrv *grpc.Server) error { - listener, err := net.Listen("tcp", cfg.Address) + var proto, addr string + parts := strings.SplitN(cfg.Address, "://", 2) + // Default to using 'tcp' to maintain backwards compatibility with configurations that don't specify + // the network to use. + if len(parts) != 2 { + proto = "tcp" + addr = cfg.Address + } else { + proto, addr = parts[0], parts[1] + } + listener, err := net.Listen(proto, addr) if err != nil { return fmt.Errorf("failed to listen on address %s: %w", cfg.Address, err) }