From d5cf6043e6ee6e42838f1a658c2a451ee9d2c167 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 11 Feb 2021 17:14:40 -0800 Subject: [PATCH] lnrpc/routerrpc: use new default value of 16 for maxparts In this commit, we raise the default value for the `MaxParts` field from 1 to 16. This change was motivated by the fact that many users either forget, or don't even know this field is there in the first place. A value of 16 was chosen rather arbitraliy (other than power of 2). In the future, we should tune this value based on the expected number of payment attempts for a given payment amount. --- lnrpc/routerrpc/router_backend.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 0756770d4..1e2b5ccd5 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -24,6 +24,15 @@ import ( "github.com/lightningnetwork/lnd/zpay32" ) +const ( + // DefaultMaxParts is the default number of splits we'll possibly use + // for MPP when the user is attempting to send a payment. + // + // TODO(roasbeef): make this value dynamic based on expected number of + // attempts for given amount + DefaultMaxParts = 16 +) + // RouterBackend contains the backend implementation of the router rpc sub // server calls. type RouterBackend struct { @@ -554,11 +563,12 @@ func (r *RouterBackend) extractIntentFromSendRequest( } payIntent.CltvLimit = cltvLimit - // Take max htlcs from the request. Map zero to one for backwards - // compatibility. + // Attempt to parse the max parts value set by the user, if this value + // isn't set, then we'll use the current default value for this + // setting. maxParts := rpcPayReq.MaxParts if maxParts == 0 { - maxParts = 1 + maxParts = DefaultMaxParts } payIntent.MaxParts = maxParts