diff --git a/peer.go b/peer.go index d514c70b..0bd3eff0 100644 --- a/peer.go +++ b/peer.go @@ -2857,6 +2857,20 @@ func (p *peer) handleCloseMsg(msg *closeMsg) { p.finalizeChanClosure(chanCloser) } +// HandleLocalCloseChanReqs accepts a *htlcswitch.ChanClose and passes it onto +// the channelManager goroutine, which will shut down the link and possibly +// close the channel. +func (p *peer) HandleLocalCloseChanReqs(req *htlcswitch.ChanClose) { + select { + case p.localCloseChanReqs <- req: + peerLog.Infof("Local close channel request delivered to peer: %v", + p.PubKey()) + case <-p.quit: + peerLog.Infof("Unable to deliver local close channel request to peer "+ + "%x", p.PubKey()) + } +} + // LinkUpdater is an interface implemented by most messages in BOLT 2 that are // allowed to update the channel state. type LinkUpdater interface { diff --git a/server.go b/server.go index f3ac2201..e0e1084b 100644 --- a/server.go +++ b/server.go @@ -491,15 +491,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, chanDB *channeldb.DB, return } - select { - case peer.localCloseChanReqs <- request: - srvrLog.Infof("Local close channel request "+ - "delivered to peer: %x", pubKey[:]) - case <-peer.quit: - srvrLog.Errorf("Unable to deliver local close "+ - "channel request to peer %x, err: %v", - pubKey[:], err) - } + peer.HandleLocalCloseChanReqs(request) }, FwdingLog: chanDB.ForwardingLog(), SwitchPackager: channeldb.NewSwitchPackager(),