lnwire+htlcswitch: only use references for failure messages

Methods on failure message types used to be defined on value receivers.
This allowed assignment of a failure message to ForwardingError both as
a value and as a pointer. This is error-prone, especially when using a
type switch.

In this commit the failure message methods are changed so that they
target pointer receivers.

Two instances where a value was assigned instead of a reference are
fixed.
This commit is contained in:
Joost Jager
2019-07-03 12:51:13 +02:00
parent 418fe364de
commit c6f9517e48
4 changed files with 36 additions and 36 deletions

View File

@@ -1214,7 +1214,7 @@ func (l *channelLink) processHodlEvent(hodlEvent invoices.HodlEvent,
)
case invoices.CancelExpiryTooSoon:
failure = lnwire.FailFinalExpiryTooSoon{}
failure = &lnwire.FailFinalExpiryTooSoon{}
default:
return fmt.Errorf("unknown cancel reason: %v",

View File

@@ -981,7 +981,7 @@ func (s *Switch) parseFailedPayment(deobfuscator ErrorDecrypter,
return &ForwardingError{
FailureSourceIdx: 0,
ExtraMsg: userErr,
FailureMessage: lnwire.FailPermanentChannelFailure{},
FailureMessage: &lnwire.FailPermanentChannelFailure{},
}
// A regular multi-hop payment error that we'll need to