routing: if MaxShardAmt is set, then use that as a ceiling for our splits

In this commit, we thread through the necessary state to allow users to
set a max shard amount. If this value is set, then this'll effectively
serve as a ceiling for all our split attempts. If we need to split,
we'll first try to use `paymentAmt/2`, if that's bigger than
`MaxShardAmt, then we'll use the latter instead.

Ideally in the future we have a dynamic way to automatically set both
the `MaxShardAmt` as well as `MaxParts` for users. Until then exposing
these two new fields will allow us to experiment with setting them
automatically using the RPC interface, and also give users a bit more
control over how we attempt to route payments, akin to coin control for
on-chain payments.

Fixes #4730
This commit is contained in:
Olaoluwa Osuntokun committed 2021-02-15 19:31:52 -08:00
1 parent 7398e59927
commit b73a6e2c61
4 files changed
+57 -1

No files matched your search

@@ -28,6 +28,7 @@ type integratedRoutingContext struct {
target *mockNode
amt lnwire.MilliSatoshi
maxShardAmt *lnwire.MilliSatoshi
finalExpiry int32
mcCfg MissionControlConfig
@@ -151,6 +152,10 @@ func (c *integratedRoutingContext) testPayment(maxParts uint32,
MaxParts: maxParts,
}
if c.maxShardAmt != nil {
payment.MaxShardAmt = c.maxShardAmt
}
session, err := newPaymentSession(
&payment, getBandwidthHints,
func() (routingGraph, func(), error) {