mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: ensure we don't dispatch local HTLC's to link that aren't eligible to forward
This commit fixes an existing bug wherein we would incorrectly attempt to forward and HTLC to a link that wasn’t yet eligible for forwarding. This would occur when we’ve added a link to the switch, but haven’t yet received a FundingLocked message for the channel. As a result, the channel won’t have the next revocation point available. A logic error prior to this commit would skip tallying the largest bandwidth rather than skipping examining the link all together. Fixes #464.
This commit is contained in:
parent
ce6dee6ee4
commit
8a7085f8b4
@ -365,9 +365,14 @@ func (s *Switch) handleLocalDispatch(payment *pendingPayment, packet *htlcPacket
|
||||
largestBandwidth lnwire.MilliSatoshi
|
||||
)
|
||||
for _, link := range links {
|
||||
// We'll skip any links that aren't yet eligible for
|
||||
// forwarding.
|
||||
if !link.EligibleToForward() {
|
||||
continue
|
||||
}
|
||||
|
||||
bandwidth := link.Bandwidth()
|
||||
if link.EligibleToForward() &&
|
||||
bandwidth > largestBandwidth {
|
||||
if bandwidth > largestBandwidth {
|
||||
|
||||
largestBandwidth = bandwidth
|
||||
}
|
||||
@ -490,8 +495,13 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
// bandwidth.
|
||||
var destination ChannelLink
|
||||
for _, link := range interfaceLinks {
|
||||
if link.EligibleToForward() &&
|
||||
link.Bandwidth() >= htlc.Amount {
|
||||
// We'll skip any links that aren't yet eligible for
|
||||
// forwarding.
|
||||
if !link.EligibleToForward() {
|
||||
continue
|
||||
}
|
||||
|
||||
if link.Bandwidth() >= htlc.Amount {
|
||||
|
||||
destination = link
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user