From be1a96b78ae673e3b54ea179827a2bdf354a6aa2 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 5 Dec 2017 17:49:55 -0800 Subject: [PATCH] htlcswitch: ensure links are eligible to forward when selecting outgoing links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- htlcswitch/switch.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index dda6b911..5bc3d3cb 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -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 }