htlcswitch+routing: type check on ClearTextError

Update the type check used for checking local payment
failures to check on the ClearTextError interface rather
than on the ForwardingError type. This change prepares
for splitting payment errors up into Link and Forwarding
errors.
This commit is contained in:
carla committed 2020-01-14 15:07:42 +02:00
1 parent 6a83b06ab7
commit b5a2d75465
5 files changed
+94 -62

No files matched your search

+12 -3
View File
@@ -326,12 +326,12 @@ func marshallError(sendError error) (*Failure, error) {
return response, nil
}
fErr, ok := sendError.(*htlcswitch.ForwardingError)
rtErr, ok := sendError.(htlcswitch.ClearTextError)
if !ok {
return nil, sendError
}
switch onionErr := fErr.WireMessage().(type) {
switch onionErr := rtErr.WireMessage().(type) {
case *lnwire.FailIncorrectDetails:
response.Code = Failure_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
@@ -425,7 +425,16 @@ func marshallError(sendError error) (*Failure, error) {
return nil, fmt.Errorf("cannot marshall failure %T", onionErr)
}
response.FailureSourceIndex = uint32(fErr.FailureSourceIdx)
// If the ClearTextError received is a ForwardingError, the error
// originated from a node along the route, not locally on our outgoing
// link. We set failureSourceIdx to the index of the node where the
// failure occurred. If the error is not a ForwardingError, the failure
// occurred at our node, so we leave the index as 0 to indicate that
// we failed locally.
fErr, ok := rtErr.(*htlcswitch.ForwardingError)
if ok {
response.FailureSourceIndex = uint32(fErr.FailureSourceIdx)
}
return response, nil
}