Skip to content

Commit 26c0c17

Browse files
committed
loopd+cli: set max gRPC message receive size
1 parent d446d68 commit 26c0c17

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cmd/loop/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ var (
3030
maxRoutingFeeRate = int64(20000)
3131

3232
defaultSwapWaitTime = 30 * time.Minute
33+
34+
// maxMsgRecvSize is the largest message our client will receive. We
35+
// set this to 200MiB atm.
36+
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
3337
)
3438

3539
func printJSON(resp interface{}) {
@@ -233,6 +237,7 @@ func logSwap(swap *looprpc.SwapStatus) {
233237
func getClientConn(address string) (*grpc.ClientConn, error) {
234238
opts := []grpc.DialOption{
235239
grpc.WithInsecure(),
240+
grpc.WithDefaultCallOptions(maxMsgRecvSize),
236241
}
237242

238243
conn, err := grpc.Dial(address, opts...)

loopd/daemon.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import (
2020
"google.golang.org/grpc"
2121
)
2222

23+
var (
24+
// maxMsgRecvSize is the largest message our REST proxy will receive. We
25+
// set this to 200MiB atm.
26+
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
27+
)
28+
2329
// listenerCfg holds closures used to retrieve listeners for the gRPC services.
2430
type listenerCfg struct {
2531
// grpcListener returns a listener to use for the gRPC server.
@@ -113,7 +119,10 @@ func daemon(config *config, lisCfg *listenerCfg) error {
113119
ctx, cancel := context.WithCancel(context.Background())
114120
defer cancel()
115121
mux := proxy.NewServeMux(customMarshalerOption)
116-
proxyOpts := []grpc.DialOption{grpc.WithInsecure()}
122+
proxyOpts := []grpc.DialOption{
123+
grpc.WithInsecure(),
124+
grpc.WithDefaultCallOptions(maxMsgRecvSize),
125+
}
117126
err = looprpc.RegisterSwapClientHandlerFromEndpoint(
118127
ctx, mux, config.RPCListen, proxyOpts,
119128
)

0 commit comments

Comments
 (0)