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:
parent
eb1167cc52
commit
164250d1cd
@ -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
|
// 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 {
|
func (s *Switch) HasActiveLink(chanID lnwire.ChannelID) bool {
|
||||||
s.indexMtx.RLock()
|
s.indexMtx.RLock()
|
||||||
defer s.indexMtx.RUnlock()
|
defer s.indexMtx.RUnlock()
|
||||||
|
|
||||||
_, ok := s.linkIndex[chanID]
|
if link, ok := s.linkIndex[chanID]; ok {
|
||||||
return ok
|
return link.EligibleToForward()
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveLink purges the switch of any link associated with chanID. If a pending
|
// RemoveLink purges the switch of any link associated with chanID. If a pending
|
||||||
|
Loading…
Reference in New Issue
Block a user