Skip to content

Commit

Permalink
lnd: allow large GRPC messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bhandras committed Jan 24, 2022
1 parent 996be21 commit eeea141
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/lncli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (

// maxMsgRecvSize is the largest message our client will receive. We
// set this to 200MiB atm.
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)
)

func fatal(err error) {
Expand Down
5 changes: 4 additions & 1 deletion lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,

rpcServerOpts := interceptorChain.CreateServerOpts()
serverOpts = append(serverOpts, rpcServerOpts...)
serverOpts = append(
serverOpts, grpc.MaxRecvMsgSize(lnrpc.MaxGrpcMsgSize),
)

grpcServer := grpc.NewServer(serverOpts...)
defer grpcServer.Stop()
Expand Down Expand Up @@ -771,7 +774,7 @@ func getTLSConfig(cfg *Config) ([]grpc.ServerOption, []grpc.DialOption,
restDialOpts := []grpc.DialOption{
grpc.WithTransportCredentials(restCreds),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200),
grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize),
),
}

Expand Down
4 changes: 4 additions & 0 deletions lnrpc/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ var (
regexp.MustCompile("^/v1/channels/transaction-stream$"),
regexp.MustCompile("^/v2/router/htlcinterceptor$"),
}

// MaxGrpcMsgSize is used when we configure both server and clients to
// allow sending/receiving at most 200 MiB GRPC messages.
MaxGrpcMsgSize = 200 * 1024 * 1024
)

0 comments on commit eeea141

Please sign in to comment.