loopd+cli: set max gRPC message receive size

pull/140/head
Oliver Gugger 4 years ago
parent d446d68eeb
commit 26c0c17dbd
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -30,6 +30,10 @@ var (
maxRoutingFeeRate = int64(20000) maxRoutingFeeRate = int64(20000)
defaultSwapWaitTime = 30 * time.Minute defaultSwapWaitTime = 30 * time.Minute
// maxMsgRecvSize is the largest message our client will receive. We
// set this to 200MiB atm.
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
) )
func printJSON(resp interface{}) { func printJSON(resp interface{}) {
@ -233,6 +237,7 @@ func logSwap(swap *looprpc.SwapStatus) {
func getClientConn(address string) (*grpc.ClientConn, error) { func getClientConn(address string) (*grpc.ClientConn, error) {
opts := []grpc.DialOption{ opts := []grpc.DialOption{
grpc.WithInsecure(), grpc.WithInsecure(),
grpc.WithDefaultCallOptions(maxMsgRecvSize),
} }
conn, err := grpc.Dial(address, opts...) conn, err := grpc.Dial(address, opts...)

@ -20,6 +20,12 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
var (
// maxMsgRecvSize is the largest message our REST proxy will receive. We
// set this to 200MiB atm.
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
)
// listenerCfg holds closures used to retrieve listeners for the gRPC services. // listenerCfg holds closures used to retrieve listeners for the gRPC services.
type listenerCfg struct { type listenerCfg struct {
// grpcListener returns a listener to use for the gRPC server. // grpcListener returns a listener to use for the gRPC server.
@ -113,7 +119,10 @@ func daemon(config *config, lisCfg *listenerCfg) error {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
mux := proxy.NewServeMux(customMarshalerOption) mux := proxy.NewServeMux(customMarshalerOption)
proxyOpts := []grpc.DialOption{grpc.WithInsecure()} proxyOpts := []grpc.DialOption{
grpc.WithInsecure(),
grpc.WithDefaultCallOptions(maxMsgRecvSize),
}
err = looprpc.RegisterSwapClientHandlerFromEndpoint( err = looprpc.RegisterSwapClientHandlerFromEndpoint(
ctx, mux, config.RPCListen, proxyOpts, ctx, mux, config.RPCListen, proxyOpts,
) )

Loading…
Cancel
Save