chancloser+cnct: disable channel before closing

This commit is contained in:
Conner Fromknecht 2019-03-12 17:34:28 -07:00
parent 3371c5fab0
commit 325d77c431
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
2 changed files with 16 additions and 20 deletions

@ -427,6 +427,14 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b
} }
c.closingTx = closeTx c.closingTx = closeTx
// Before closing, we'll attempt to send a disable update for
// the channel. We do so before closing the channel as otherwise
// the current edge policy won't be retrievable from the graph.
if err := c.cfg.disableChannel(c.chanPoint); err != nil {
peerLog.Warnf("Unable to disable channel %v on "+
"close: %v", c.chanPoint, err)
}
// With the closing transaction crafted, we'll now broadcast it // With the closing transaction crafted, we'll now broadcast it
// to the network. // to the network.
peerLog.Infof("Broadcasting cooperative close tx: %v", peerLog.Infof("Broadcasting cooperative close tx: %v",
@ -440,16 +448,6 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b
return nil, false, err return nil, false, err
} }
// We'll attempt to disable the channel in the background to
// avoid blocking due to sending the update message to all
// active peers.
go func() {
if err := c.cfg.disableChannel(c.chanPoint); err != nil {
peerLog.Errorf("Unable to disable channel %v on "+
"close: %v", c.chanPoint, err)
}
}()
// Finally, we'll transition to the closeFinished state, and // Finally, we'll transition to the closeFinished state, and
// also return the final close signed message we sent. // also return the final close signed message we sent.
// Additionally, we return true for the second argument to // Additionally, we return true for the second argument to

@ -635,6 +635,14 @@ func (c *ChainArbitrator) ForceCloseContract(chanPoint wire.OutPoint) (*wire.Msg
log.Infof("Attempting to force close ChannelPoint(%v)", chanPoint) log.Infof("Attempting to force close ChannelPoint(%v)", chanPoint)
// Before closing, we'll attempt to send a disable update for the
// channel. We do so before closing the channel as otherwise the current
// edge policy won't be retrievable from the graph.
if err := c.cfg.DisableChannel(chanPoint); err != nil {
log.Warnf("Unable to disable channel %v on "+
"close: %v", chanPoint, err)
}
errChan := make(chan error, 1) errChan := make(chan error, 1)
respChan := make(chan *wire.MsgTx, 1) respChan := make(chan *wire.MsgTx, 1)
@ -667,16 +675,6 @@ func (c *ChainArbitrator) ForceCloseContract(chanPoint wire.OutPoint) (*wire.Msg
return nil, ErrChainArbExiting return nil, ErrChainArbExiting
} }
// We'll attempt to disable the channel in the background to
// avoid blocking due to sending the update message to all
// active peers.
go func() {
if err := c.cfg.DisableChannel(chanPoint); err != nil {
log.Errorf("Unable to disable channel %v on "+
"close: %v", chanPoint, err)
}
}()
return closeTx, nil return closeTx, nil
} }