rpc: wrap canceling a breach watch in a select case

This commit is contained in:
Olaoluwa Osuntokun 2017-08-03 16:40:08 -07:00
parent c183e8984c
commit d39410cc01
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 6 additions and 1 deletions

@ -613,7 +613,11 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
r.server.htlcSwitch.RemoveLink(chanID) r.server.htlcSwitch.RemoveLink(chanID)
} }
r.server.breachArbiter.settledContracts <- chanPoint select {
case r.server.breachArbiter.settledContracts <- chanPoint:
case <-r.quit:
return fmt.Errorf("server shutting down")
}
// With the necessary indexes cleaned up, we'll now force close // With the necessary indexes cleaned up, we'll now force close
// the channel. // the channel.

@ -165,6 +165,7 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
s.htlcSwitch = htlcswitch.New(htlcswitch.Config{ s.htlcSwitch = htlcswitch.New(htlcswitch.Config{
LocalChannelClose: func(pubKey []byte, LocalChannelClose: func(pubKey []byte,
request *htlcswitch.ChanClose) { request *htlcswitch.ChanClose) {
s.peersMtx.RLock() s.peersMtx.RLock()
peer, ok := s.peersByPub[string(pubKey)] peer, ok := s.peersByPub[string(pubKey)]
s.peersMtx.RUnlock() s.peersMtx.RUnlock()