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

View File

@ -613,7 +613,11 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
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
// the channel.

View File

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