rpc: wrap canceling a breach watch in a select case

This commit is contained in:
Olaoluwa Osuntokun committed 2017-08-03 16:40:15 -07:00
1 parent c183e8984c
commit d39410cc01
2 files changed
+6 -1

No files matched your search

+5 -1
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.
+1
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()