mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-20 04:21:37 +02:00
htlcswitch: ensure links are eligible to forward when selecting outgoing links
In this commit, when selecting a candidate link to forward a payment, we’ll ensure that it’s actually able to take on the HTLC. Otherwise, we’ll skip over the link itself. Currently, a link is only fully eligible for forwarding, *after* we’ve received and fully processed the FundingLocked message.
This commit is contained in:
@@ -366,7 +366,9 @@ func (s *Switch) handleLocalDispatch(payment *pendingPayment, packet *htlcPacket
|
|||||||
)
|
)
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
bandwidth := link.Bandwidth()
|
bandwidth := link.Bandwidth()
|
||||||
if bandwidth > largestBandwidth {
|
if link.EligibleToForward() &&
|
||||||
|
bandwidth > largestBandwidth {
|
||||||
|
|
||||||
largestBandwidth = bandwidth
|
largestBandwidth = bandwidth
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +490,9 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
|||||||
// bandwidth.
|
// bandwidth.
|
||||||
var destination ChannelLink
|
var destination ChannelLink
|
||||||
for _, link := range interfaceLinks {
|
for _, link := range interfaceLinks {
|
||||||
if link.Bandwidth() >= htlc.Amount {
|
if link.EligibleToForward() &&
|
||||||
|
link.Bandwidth() >= htlc.Amount {
|
||||||
|
|
||||||
destination = link
|
destination = link
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user