htlcswitch: replace outgoing failure with interface

Add a FailureDetail interface which allows us have different kinds of
failures for link errors. This interface will be used to cover failures
that occur when on invoice payment, because the errors have already
been enumerated in the invoices package.
This commit is contained in:
carla committed 2020-02-06 19:43:23 +02:00
1 parent bdd9411bbd
commit 9390d3bbfd
3 files changed
+23 -12

No files matched your search

+12 -2
View File
@@ -1,5 +1,13 @@
package htlcswitch
// FailureDetail is an interface implemented by failures that occur on
// our incoming or outgoing link, or within the switch itself.
type FailureDetail interface {
// FailureString returns the string representation of a failure
// detail.
FailureString() string
}
// OutgoingFailure is an enum which is used to enrich failures which occur in
// the switch or on our outgoing link with additional metadata.
type OutgoingFailure int
@@ -36,8 +44,10 @@ const (
OutgoingFailureCircularRoute
)
// String returns the string representation of a failure detail.
func (fd OutgoingFailure) String() string {
// FailureString returns the string representation of a failure detail.
//
// Note: it is part of the FailureDetail interface.
func (fd OutgoingFailure) FailureString() string {
switch fd {
case OutgoingFailureNone:
return "no failure detail"