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:
Olaoluwa Osuntokun 2017-12-05 17:49:55 -08:00
parent 36956d390f
commit be1a96b78a
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -366,7 +366,9 @@ func (s *Switch) handleLocalDispatch(payment *pendingPayment, packet *htlcPacket
)
for _, link := range links {
bandwidth := link.Bandwidth()
if bandwidth > largestBandwidth {
if link.EligibleToForward() &&
bandwidth > largestBandwidth {
largestBandwidth = bandwidth
}
@ -488,7 +490,9 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
// bandwidth.
var destination ChannelLink
for _, link := range interfaceLinks {
if link.Bandwidth() >= htlc.Amount {
if link.EligibleToForward() &&
link.Bandwidth() >= htlc.Amount {
destination = link
break
}