routing: properly prune edges that return a FailPermanentChannelFailure

In this commit, we now account for a case where a node sends us a
FailPermanentChannelFailure during a payment attempt. Before this
commit, we wouldn’t properly prune the edge to avoid re-using it. We
remedy this by properly attempting to prune the edge if possible.
Future changes well send a FailPermanentChannelFailure in the case that
we ned to go on-chain for an outgoing HTLC, and cancel back the
incoming HTLC.
This commit is contained in:
Olaoluwa Osuntokun 2018-01-16 18:54:41 -08:00
parent b396d438bb
commit eba6ba0760
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 24 additions and 1 deletions

View File

@ -1735,8 +1735,31 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route
// we'll note this (exclude the vertex/edge), and
// continue with the rest of the routes.
case *lnwire.FailPermanentChannelFailure:
// TODO(roasbeef): remove channel from path
// As this error indicates that the target
// channel was unable to carry this HTLC (for
// w/e reason), we'll query the index to find
// the _outgoign_ channel the source of the
// error was meant to pass the HTLC along to.
badChan, ok := route.nextHopChannel(errSource)
if !ok {
// If we weren't able to find the hop
// *after* this node, then we'll
// attempt to disable the previous
// channel.
badChan, ok = route.prevHopChannel(
errSource,
)
if !ok {
continue
}
}
// If the channel was found, then we'll inform
// mission control of this failure so future
// attempts avoid this link temporarily.
paySession.ReportChannelFailure(badChan.ChannelID)
continue
case *lnwire.FailPermanentNodeFailure:
// TODO(rosabeef): remove node from path
continue