htlcswitch/switch: add method HasActiveLink

This commit is contained in:
Johan T. Halseth committed 2018-08-17 23:24:12 +02:00
1 parent 940d0735f8
commit 887722f38f
1 file changed
+10
+10
View File
@@ -1902,6 +1902,16 @@ func (s *Switch) getLinkByShortID(chanID lnwire.ShortChannelID) (ChannelLink, er
return link, nil
}
// HasActiveLink returns true if the given channel ID has a link in the link
// index.
func (s *Switch) HasActiveLink(chanID lnwire.ChannelID) bool {
s.indexMtx.RLock()
defer s.indexMtx.RUnlock()
_, ok := s.linkIndex[chanID]
return ok
}
// RemoveLink purges the switch of any link associated with chanID. If a pending
// or active link is not found, this method does nothing. Otherwise, the method
// returns after the link has been completely shutdown.