htlcswitch+routing+routerrpc: return error source as index

This commit is contained in:
Joost Jager committed 2019-07-11 10:37:26 +02:00
1 parent 55bef96cf3
commit 2b47632b26
11 files changed
+245 -310

No files matched your search

+19 -25
View File
@@ -9,7 +9,6 @@ import (
"sync/atomic"
"time"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/coreos/bbolt"
@@ -112,11 +111,6 @@ type ChanClose struct {
// Config defines the configuration for the service. ALL elements within the
// configuration MUST be non-nil for the service to carry out its duties.
type Config struct {
// SelfKey is the key of the backing Lightning node. This key is used
// to properly craft failure messages, such that the Layer 3 router can
// properly route around link./vertex failures.
SelfKey *btcec.PublicKey
// FwdingLog is an interface that will be used by the switch to log
// forwarding events. A forwarding event happens each time a payment
// circuit is successfully completed. So when we forward an HTLC, and a
@@ -776,8 +770,8 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error {
if err != nil {
log.Errorf("Link %v not found", pkt.outgoingChanID)
return &ForwardingError{
ErrorSource: s.cfg.SelfKey,
FailureMessage: &lnwire.FailUnknownNextPeer{},
FailureSourceIdx: 0,
FailureMessage: &lnwire.FailUnknownNextPeer{},
}
}
@@ -790,9 +784,9 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error {
// will be returned back to the router.
htlcErr := lnwire.NewTemporaryChannelFailure(nil)
return &ForwardingError{
ErrorSource: s.cfg.SelfKey,
ExtraMsg: err.Error(),
FailureMessage: htlcErr,
FailureSourceIdx: 0,
ExtraMsg: err.Error(),
FailureMessage: htlcErr,
}
}
@@ -808,8 +802,8 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error {
"satisfied", pkt.outgoingChanID)
return &ForwardingError{
ErrorSource: s.cfg.SelfKey,
FailureMessage: htlcErr,
FailureSourceIdx: 0,
FailureMessage: htlcErr,
}
}
@@ -823,9 +817,9 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error {
// will be returned back to the router.
htlcErr := lnwire.NewTemporaryChannelFailure(nil)
return &ForwardingError{
ErrorSource: s.cfg.SelfKey,
ExtraMsg: err.Error(),
FailureMessage: htlcErr,
FailureSourceIdx: 0,
ExtraMsg: err.Error(),
FailureMessage: htlcErr,
}
}
@@ -967,9 +961,9 @@ func (s *Switch) parseFailedPayment(deobfuscator ErrorDecrypter,
failureMsg = lnwire.NewTemporaryChannelFailure(nil)
}
failure = &ForwardingError{
ErrorSource: s.cfg.SelfKey,
ExtraMsg: userErr,
FailureMessage: failureMsg,
FailureSourceIdx: 0,
ExtraMsg: userErr,
FailureMessage: failureMsg,
}
// A payment had to be timed out on chain before it got past
@@ -981,9 +975,9 @@ func (s *Switch) parseFailedPayment(deobfuscator ErrorDecrypter,
"on-chain, then cancelled back (hash=%v, pid=%d)",
paymentHash, paymentID)
failure = &ForwardingError{
ErrorSource: s.cfg.SelfKey,
ExtraMsg: userErr,
FailureMessage: lnwire.FailPermanentChannelFailure{},
FailureSourceIdx: 0,
ExtraMsg: userErr,
FailureMessage: lnwire.FailPermanentChannelFailure{},
}
// A regular multi-hop payment error that we'll need to
@@ -999,9 +993,9 @@ func (s *Switch) parseFailedPayment(deobfuscator ErrorDecrypter,
paymentHash, paymentID, err)
log.Error(userErr)
failure = &ForwardingError{
ErrorSource: s.cfg.SelfKey,
ExtraMsg: userErr,
FailureMessage: lnwire.NewTemporaryChannelFailure(nil),
FailureSourceIdx: 0,
ExtraMsg: userErr,
FailureMessage: lnwire.NewTemporaryChannelFailure(nil),
}
}
}