peer: mark channel borked in case of PermanentFailure

This commit is contained in:
Johan T. Halseth 2018-10-08 15:46:14 +02:00
parent a6d2263569
commit a97182b1e9
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

View File

@ -2496,6 +2496,13 @@ type linkFailureReport struct {
// force closing the channel depending on severity, and sending the error
// message back to the remote party.
func (p *Brontide) handleLinkFailure(failure linkFailureReport) {
// Retrieve the channel from the map of active channels. We do this to
// have access to it even after WipeChannel remove it from the map.
chanID := lnwire.NewChanIDFromOutPoint(&failure.chanPoint)
p.activeChanMtx.Lock()
lnChan := p.activeChannels[chanID]
p.activeChanMtx.Unlock()
// We begin by wiping the link, which will remove it from the switch,
// such that it won't be attempted used for any more updates.
//
@ -2524,6 +2531,17 @@ func (p *Brontide) handleLinkFailure(failure linkFailureReport) {
}
}
// If this is a permanent failure, we will mark the channel borked.
if failure.linkErr.PermanentFailure && lnChan != nil {
peerLog.Warnf("Marking link(%v) borked due to permanent "+
"failure", failure.shortChanID)
if err := lnChan.State().MarkBorked(); err != nil {
peerLog.Errorf("Unable to mark channel %v borked: %v",
failure.shortChanID, err)
}
}
// Send an error to the peer, why we failed the channel.
if failure.linkErr.ShouldSendToPeer() {
// If SendData is set, send it to the peer. If not, we'll use