Change message size limits to 100MB

This commit is contained in:
msutton 2022-07-16 22:50:48 +03:00
parent e2cb414301
commit 7dd62a9230
2 changed files with 12 additions and 3 deletions

View File

@ -13,10 +13,16 @@ import (
// Connect connects to the kaspawalletd server, and returns the client instance // Connect connects to the kaspawalletd server, and returns the client instance
func Connect(address string) (pb.KaspawalletdClient, func(), error) { func Connect(address string) (pb.KaspawalletdClient, func(), error) {
// Connection is local, so 1 second timeout is sufficient // Connection is local, so 1 second timeout is sufficient
ctx, cancel := context.WithTimeout(context.Background(), time.Second) ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel() defer cancel()
conn, err := grpc.DialContext(ctx, address, grpc.WithInsecure(), grpc.WithBlock()) const maxMsgSize = 100_000_000
conn, err := grpc.DialContext(
ctx, address,
grpc.WithInsecure(),
grpc.WithBlock(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize), grpc.MaxCallSendMsgSize(maxMsgSize)))
if err != nil { if err != nil {
if errors.Is(err, context.DeadlineExceeded) { if errors.Is(err, context.DeadlineExceeded) {
return nil, nil, errors.New("kaspawallet daemon is not running, start it with `kaspawallet start-daemon`") return nil, nil, errors.New("kaspawallet daemon is not running, start it with `kaspawallet start-daemon`")

View File

@ -96,7 +96,10 @@ func Start(params *dagconfig.Params, listen, rpcServer string, keysFilePath stri
} }
}) })
grpcServer := grpc.NewServer() const maxMsgSize = 100_000_000
grpcServer := grpc.NewServer(
grpc.MaxRecvMsgSize(maxMsgSize),
grpc.MaxSendMsgSize(maxMsgSize))
pb.RegisterKaspawalletdServer(grpcServer, serverInstance) pb.RegisterKaspawalletdServer(grpcServer, serverInstance)
spawn("grpcServer.Serve", func() { spawn("grpcServer.Serve", func() {