From 887722f38ffc4b2953284f898305a3b943694e06 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 9 Aug 2018 10:03:14 +0200 Subject: [PATCH] htlcswitch/switch: add method HasActiveLink --- htlcswitch/switch.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index ecb56a5f5..74e0a2787 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -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.