htlcswitch: add linkError field to htlcpacket

This commit adds a linkError field to track the value of failures
which occur at our node. This field is set when local payments or
multi hop htlcs fail in the switch or on our outgoing link. This
addition is required for the addition of a htlc notifier which will
notify these failures in handleDownstreamPacket.

The passing of link error to failAddPacket removes the need for an
additional error field, because the link error's failure detail will
contain any additional metadata. In the places where the failure detail
does not cover all the metadata that was previously supplied by addr
err, the error is logged before calling failAddPacket so that this
change does not reduce the amount of information we log.
This commit is contained in:
carla committed 2020-02-06 19:43:29 +02:00
1 parent 9390d3bbfd
commit 74e0d545fe
6 files changed
+102 -44

No files matched your search

+21
View File
@@ -42,6 +42,18 @@ const (
// to forward a htlc through our node which arrives and leaves on the
// same channel.
OutgoingFailureCircularRoute
// OutgoingFailureIncompleteForward is returned when we cancel an incomplete
// forward.
OutgoingFailureIncompleteForward
// OutgoingFailureDownstreamHtlcAdd is returned when we fail to add a
// downstream htlc to our outgoing link.
OutgoingFailureDownstreamHtlcAdd
// OutgoingFailureForwardsDisabled is returned when the switch is
// configured to disallow forwards.
OutgoingFailureForwardsDisabled
)
// FailureString returns the string representation of a failure detail.
@@ -70,6 +82,15 @@ func (fd OutgoingFailure) FailureString() string {
case OutgoingFailureCircularRoute:
return "same incoming and outgoing channel"
case OutgoingFailureIncompleteForward:
return "failed after detecting incomplete forward"
case OutgoingFailureDownstreamHtlcAdd:
return "could not add downstream htlc"
case OutgoingFailureForwardsDisabled:
return "node configured to disallow forwards"
default:
return "unknown failure detail"
}