mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-14 02:41:47 +02:00
routing: handle both amounts equally
We duplicate the function calls to handle the min amount and known amount cases in a similar manner, to make the next diff easier to parse.
This commit is contained in:
parent
2edbe6b878
commit
e4c7c10618
@ -1441,32 +1441,46 @@ func (r *ChannelRouter) BuildRoute(amt *lnwire.MilliSatoshi,
|
|||||||
// amount that this route can carry.
|
// amount that this route can carry.
|
||||||
useMinAmt := amt == nil
|
useMinAmt := amt == nil
|
||||||
|
|
||||||
var runningAmt lnwire.MilliSatoshi
|
var (
|
||||||
|
receiverAmt lnwire.MilliSatoshi
|
||||||
|
pathEdges []*unifiedEdge
|
||||||
|
)
|
||||||
|
|
||||||
if useMinAmt {
|
if useMinAmt {
|
||||||
// For minimum amount routes, aim to deliver at least 1 msat to
|
// For minimum amount routes, aim to deliver at least 1 msat to
|
||||||
// the destination. There are nodes in the wild that have a
|
// the destination. There are nodes in the wild that have a
|
||||||
// min_htlc channel policy of zero, which could lead to a zero
|
// min_htlc channel policy of zero, which could lead to a zero
|
||||||
// amount payment being made.
|
// amount payment being made.
|
||||||
runningAmt = 1
|
|
||||||
} else {
|
|
||||||
// If an amount is specified, we need to build a route that
|
|
||||||
// delivers exactly this amount to the final destination.
|
|
||||||
runningAmt = *amt
|
|
||||||
}
|
|
||||||
|
|
||||||
senderAmt, err := senderAmtBackwardPass(
|
senderAmt, err := senderAmtBackwardPass(
|
||||||
unifiers, useMinAmt, runningAmt, bandwidthHints,
|
unifiers, useMinAmt, 1, bandwidthHints,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pathEdges, receiverAmt, err := getPathEdges(
|
pathEdges, receiverAmt, err = getPathEdges(
|
||||||
senderAmt, unifiers, bandwidthHints,
|
senderAmt, unifiers, bandwidthHints,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// If an amount is specified, we need to build a route that
|
||||||
|
// delivers exactly this amount to the final destination.
|
||||||
|
senderAmt, err := senderAmtBackwardPass(
|
||||||
|
unifiers, useMinAmt, *amt, bandwidthHints,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pathEdges, receiverAmt, err = getPathEdges(
|
||||||
|
senderAmt, unifiers, bandwidthHints,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the current block height outside the routing transaction, to
|
// Fetch the current block height outside the routing transaction, to
|
||||||
// prevent the rpc call blocking the database.
|
// prevent the rpc call blocking the database.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user