htlcswitch+peer: CreateAndAddLink in switch, add messageSwitch to peer

This commit allows the peer to be tested without relying on a raw
htlcswitch.Switch pointer. This is accomplished by using a messageSwitch
interface and adding the CreateAndAddLink method to the
htlcswitch.Switch.
This commit is contained in:
eugene committed 2021-08-10 17:15:52 -04:00
1 parent e72468646c
commit 23a4fad4ac
4 files changed
+74 -30

No files matched your search

+9
View File
@@ -1956,6 +1956,15 @@ func (s *Switch) Stop() error {
return nil
}
// CreateAndAddLink will create a link and then add it to the internal maps
// when given a ChannelLinkConfig and LightningChannel.
func (s *Switch) CreateAndAddLink(linkCfg ChannelLinkConfig,
lnChan *lnwallet.LightningChannel) error {
link := NewChannelLink(linkCfg, lnChan)
return s.AddLink(link)
}
// AddLink is used to initiate the handling of the add link command. The
// request will be propagated and handled in the main goroutine.
func (s *Switch) AddLink(link ChannelLink) error {