peer+server: add HandleLocalCloseChanReqs to peer, call from server

This commit is contained in:
nsa 2020-06-29 20:42:06 -04:00
parent e1632dd172
commit bf161c9835
2 changed files with 15 additions and 9 deletions

14
peer.go
View File

@ -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 {

View File

@ -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(),