routing: provide payment id to mission control

This commit is contained in:
Joost Jager 2019-06-26 11:48:59 +02:00
parent 334b6a3bfe
commit b4a7665bae
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
5 changed files with 14 additions and 11 deletions

@ -395,7 +395,7 @@ func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
// returns a bool indicating whether this error is a final error. If it is
// final, a failure reason is returned and no further payment attempts need to
// be made.
func (m *MissionControl) ReportPaymentFail(rt *route.Route,
func (m *MissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route,
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
channeldb.FailureReason) {

@ -37,6 +37,7 @@ type mcTestContext struct {
t *testing.T
mc *MissionControl
now time.Time
pid uint64
}
func createMcTestContext(t *testing.T) *mcTestContext {
@ -78,7 +79,7 @@ func (ctx *mcTestContext) reportFailure(t time.Time,
errorSourceIdx := 1
ctx.mc.ReportPaymentFail(
mcTestRoute, &errorSourceIdx, failure,
ctx.pid, mcTestRoute, &errorSourceIdx, failure,
)
}

@ -98,9 +98,9 @@ type mockMissionControl struct {
var _ MissionController = (*mockMissionControl)(nil)
func (m *mockMissionControl) ReportPaymentFail(rt *route.Route,
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
channeldb.FailureReason) {
func (m *mockMissionControl) ReportPaymentFail(paymentID uint64,
rt *route.Route, failureSourceIdx *int, failure lnwire.FailureMessage) (
bool, channeldb.FailureReason) {
return false, 0
}

@ -343,7 +343,7 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID,
func (p *paymentLifecycle) handleSendError(sendErr error) error {
final, reason := p.router.processSendError(
&p.attempt.Route, sendErr,
p.attempt.PaymentID, &p.attempt.Route, sendErr,
)
if !final {
// Save the forwarding error so it can be returned if

@ -178,7 +178,7 @@ type MissionController interface {
// input for future probability estimates. It returns a bool indicating
// whether this error is a final error and no further payment attempts
// need to be made.
ReportPaymentFail(rt *route.Route,
ReportPaymentFail(paymentID uint64, rt *route.Route,
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
channeldb.FailureReason)
@ -1893,13 +1893,15 @@ func (r *ChannelRouter) tryApplyChannelUpdate(rt *route.Route,
// error type, this error is either the final outcome of the payment or we need
// to continue with an alternative route. This is indicated by the boolean
// return value.
func (r *ChannelRouter) processSendError(rt *route.Route, sendErr error) (bool,
channeldb.FailureReason) {
func (r *ChannelRouter) processSendError(paymentID uint64, rt *route.Route,
sendErr error) (bool, channeldb.FailureReason) {
if sendErr == htlcswitch.ErrUnreadableFailureMessage {
log.Tracef("Unreadable failure when sending htlc")
return r.cfg.MissionControl.ReportPaymentFail(rt, nil, nil)
return r.cfg.MissionControl.ReportPaymentFail(
paymentID, rt, nil, nil,
)
}
// If an internal, non-forwarding error occurred, we can stop
// trying.
@ -1926,7 +1928,7 @@ func (r *ChannelRouter) processSendError(rt *route.Route, sendErr error) (bool,
failureSourceIdx)
return r.cfg.MissionControl.ReportPaymentFail(
rt, &failureSourceIdx, failureMessage,
paymentID, rt, &failureSourceIdx, failureMessage,
)
}