htlcswitch: remove extramsg string from ForwardingError

Remove the extramsg field in ForwardingError because
it has been replaced with detailed link errors.
This commit is contained in:
carla 2020-01-14 15:07:42 +02:00
parent f430fd50c5
commit ec099bf5dd
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
3 changed files with 17 additions and 26 deletions

@ -88,10 +88,6 @@ type ForwardingError struct {
// zero is the self node. // zero is the self node.
FailureSourceIdx int FailureSourceIdx int
// ExtraMsg is an additional error message that callers can provide in
// order to provide context specific error details.
ExtraMsg string
// msg is the wire message associated with the error. This value may // msg is the wire message associated with the error. This value may
// be nil in the case where we fail to decode failure message sent by // be nil in the case where we fail to decode failure message sent by
// a peer. // a peer.
@ -112,24 +108,19 @@ func (f *ForwardingError) WireMessage() lnwire.FailureMessage {
// the switch or any callers to insert additional context to the error message // the switch or any callers to insert additional context to the error message
// returned. // returned.
func (f *ForwardingError) Error() string { func (f *ForwardingError) Error() string {
if f.ExtraMsg == "" {
return fmt.Sprintf("%v@%v", f.msg, f.FailureSourceIdx)
}
return fmt.Sprintf( return fmt.Sprintf(
"%v@%v: %v", f.msg, f.FailureSourceIdx, f.ExtraMsg, "%v@%v", f.msg, f.FailureSourceIdx,
) )
} }
// NewForwardingError creates a new payment error which wraps a wire error // NewForwardingError creates a new payment error which wraps a wire error
// with additional metadata. // with additional metadata.
func NewForwardingError(failure lnwire.FailureMessage, index int, func NewForwardingError(failure lnwire.FailureMessage,
extraMsg string) *ForwardingError { index int) *ForwardingError {
return &ForwardingError{ return &ForwardingError{
FailureSourceIdx: index, FailureSourceIdx: index,
msg: failure, msg: failure,
ExtraMsg: extraMsg,
} }
} }
@ -199,7 +190,7 @@ func (s *SphinxErrorDecrypter) DecryptError(reason lnwire.OpaqueReason) (
return NewUnknownForwardingError(failure.SenderIdx), nil return NewUnknownForwardingError(failure.SenderIdx), nil
} }
return NewForwardingError(failureMsg, failure.SenderIdx, ""), nil return NewForwardingError(failureMsg, failure.SenderIdx), nil
} }
// A compile time check to ensure ErrorDecrypter implements the Deobfuscator // A compile time check to ensure ErrorDecrypter implements the Deobfuscator

@ -400,7 +400,7 @@ func (o *mockDeobfuscator) DecryptError(reason lnwire.OpaqueReason) (*Forwarding
return nil, err return nil, err
} }
return NewForwardingError(failure, 1, ""), nil return NewForwardingError(failure, 1), nil
} }
var _ ErrorDecrypter = (*mockDeobfuscator)(nil) var _ ErrorDecrypter = (*mockDeobfuscator)(nil)

@ -292,7 +292,7 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
// TODO(roasbeef): temp node failure // TODO(roasbeef): temp node failure
// should be? // should be?
&lnwire.FailTemporaryChannelFailure{}, &lnwire.FailTemporaryChannelFailure{},
1, "", 1,
) )
} }
@ -425,7 +425,7 @@ func TestChannelUpdateValidation(t *testing.T) {
&lnwire.FailFeeInsufficient{ &lnwire.FailFeeInsufficient{
Update: errChanUpdate, Update: errChanUpdate,
}, },
1, "", 1,
) )
}) })
@ -550,7 +550,7 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
// node/channel. // node/channel.
&lnwire.FailFeeInsufficient{ &lnwire.FailFeeInsufficient{
Update: errChanUpdate, Update: errChanUpdate,
}, 1, "", }, 1,
) )
} }
@ -649,7 +649,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailExpiryTooSoon{ &lnwire.FailExpiryTooSoon{
Update: errChanUpdate, Update: errChanUpdate,
}, 1, "", }, 1,
) )
} }
@ -702,7 +702,7 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailIncorrectCltvExpiry{ &lnwire.FailIncorrectCltvExpiry{
Update: errChanUpdate, Update: errChanUpdate,
}, 1, "", }, 1,
) )
} }
@ -763,7 +763,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
// sophon not having enough capacity. // sophon not having enough capacity.
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailTemporaryChannelFailure{}, &lnwire.FailTemporaryChannelFailure{},
1, "", 1,
) )
} }
@ -772,7 +772,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
// which should prune out the rest of the routes. // which should prune out the rest of the routes.
if firstHop == roasbeefPhanNuwen { if firstHop == roasbeefPhanNuwen {
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailUnknownNextPeer{}, 1, "", &lnwire.FailUnknownNextPeer{}, 1,
) )
} }
@ -803,7 +803,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
if firstHop == roasbeefSongoku { if firstHop == roasbeefSongoku {
failure := htlcswitch.NewForwardingError( failure := htlcswitch.NewForwardingError(
&lnwire.FailUnknownNextPeer{}, 1, "", &lnwire.FailUnknownNextPeer{}, 1,
) )
return [32]byte{}, failure return [32]byte{}, failure
} }
@ -850,7 +850,7 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
// roasbeef not having enough capacity. // roasbeef not having enough capacity.
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailTemporaryChannelFailure{}, &lnwire.FailTemporaryChannelFailure{},
1, "", 1,
) )
} }
return preImage, nil return preImage, nil
@ -3102,7 +3102,7 @@ func TestRouterPaymentStateMachine(t *testing.T) {
select { select {
case sendResult <- htlcswitch.NewForwardingError( case sendResult <- htlcswitch.NewForwardingError(
&lnwire.FailTemporaryChannelFailure{}, &lnwire.FailTemporaryChannelFailure{},
1, "", 1,
): ):
case <-time.After(1 * time.Second): case <-time.After(1 * time.Second):
t.Fatalf("unable to send result") t.Fatalf("unable to send result")
@ -3126,7 +3126,7 @@ func TestRouterPaymentStateMachine(t *testing.T) {
case getPaymentResultFailure: case getPaymentResultFailure:
failure := htlcswitch.NewForwardingError( failure := htlcswitch.NewForwardingError(
&lnwire.FailTemporaryChannelFailure{}, &lnwire.FailTemporaryChannelFailure{},
1, "", 1,
) )
select { select {
@ -3302,7 +3302,7 @@ func TestSendToRouteStructuredError(t *testing.T) {
return [32]byte{}, htlcswitch.NewForwardingError( return [32]byte{}, htlcswitch.NewForwardingError(
&lnwire.FailFeeInsufficient{ &lnwire.FailFeeInsufficient{
Update: lnwire.ChannelUpdate{}, Update: lnwire.ChannelUpdate{},
}, 1, "", }, 1,
) )
}) })