htlcswitch/switch: check EligibleToForward in HasActiveLink

This commit modifies the behavior of the
HasActiveLink method within the switch to
only return true if the link is in the
link index and is eligible to forward
HTLCs.

The prior version returns true whenever
the link is found in the link index,
which may return true for pending
channels that are not actually active.
This commit is contained in:
Conner Fromknecht 2019-01-10 16:34:02 -08:00
parent eb1167cc52
commit 164250d1cd
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -1990,13 +1990,16 @@ func (s *Switch) getLinkByShortID(chanID lnwire.ShortChannelID) (ChannelLink, er
}
// HasActiveLink returns true if the given channel ID has a link in the link
// index.
// index AND the link is eligible to forward.
func (s *Switch) HasActiveLink(chanID lnwire.ChannelID) bool {
s.indexMtx.RLock()
defer s.indexMtx.RUnlock()
_, ok := s.linkIndex[chanID]
return ok
if link, ok := s.linkIndex[chanID]; ok {
return link.EligibleToForward()
}
return false
}
// RemoveLink purges the switch of any link associated with chanID. If a pending