routing: provide payment id to mission control
This commit is contained in:
parent
334b6a3bfe
commit
b4a7665bae
@ -395,7 +395,7 @@ func (m *MissionControl) GetHistorySnapshot() *MissionControlSnapshot {
|
|||||||
// returns a bool indicating whether this error is a final error. If it is
|
// 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
|
// final, a failure reason is returned and no further payment attempts need to
|
||||||
// be made.
|
// be made.
|
||||||
func (m *MissionControl) ReportPaymentFail(rt *route.Route,
|
func (m *MissionControl) ReportPaymentFail(paymentID uint64, rt *route.Route,
|
||||||
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
|
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
|
||||||
channeldb.FailureReason) {
|
channeldb.FailureReason) {
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ type mcTestContext struct {
|
|||||||
t *testing.T
|
t *testing.T
|
||||||
mc *MissionControl
|
mc *MissionControl
|
||||||
now time.Time
|
now time.Time
|
||||||
|
pid uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMcTestContext(t *testing.T) *mcTestContext {
|
func createMcTestContext(t *testing.T) *mcTestContext {
|
||||||
@ -78,7 +79,7 @@ func (ctx *mcTestContext) reportFailure(t time.Time,
|
|||||||
|
|
||||||
errorSourceIdx := 1
|
errorSourceIdx := 1
|
||||||
ctx.mc.ReportPaymentFail(
|
ctx.mc.ReportPaymentFail(
|
||||||
mcTestRoute, &errorSourceIdx, failure,
|
ctx.pid, mcTestRoute, &errorSourceIdx, failure,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ type mockMissionControl struct {
|
|||||||
|
|
||||||
var _ MissionController = (*mockMissionControl)(nil)
|
var _ MissionController = (*mockMissionControl)(nil)
|
||||||
|
|
||||||
func (m *mockMissionControl) ReportPaymentFail(rt *route.Route,
|
func (m *mockMissionControl) ReportPaymentFail(paymentID uint64,
|
||||||
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
|
rt *route.Route, failureSourceIdx *int, failure lnwire.FailureMessage) (
|
||||||
channeldb.FailureReason) {
|
bool, channeldb.FailureReason) {
|
||||||
|
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ func (p *paymentLifecycle) sendPaymentAttempt(firstHop lnwire.ShortChannelID,
|
|||||||
func (p *paymentLifecycle) handleSendError(sendErr error) error {
|
func (p *paymentLifecycle) handleSendError(sendErr error) error {
|
||||||
|
|
||||||
final, reason := p.router.processSendError(
|
final, reason := p.router.processSendError(
|
||||||
&p.attempt.Route, sendErr,
|
p.attempt.PaymentID, &p.attempt.Route, sendErr,
|
||||||
)
|
)
|
||||||
if !final {
|
if !final {
|
||||||
// Save the forwarding error so it can be returned if
|
// 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
|
// input for future probability estimates. It returns a bool indicating
|
||||||
// whether this error is a final error and no further payment attempts
|
// whether this error is a final error and no further payment attempts
|
||||||
// need to be made.
|
// need to be made.
|
||||||
ReportPaymentFail(rt *route.Route,
|
ReportPaymentFail(paymentID uint64, rt *route.Route,
|
||||||
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
|
failureSourceIdx *int, failure lnwire.FailureMessage) (bool,
|
||||||
channeldb.FailureReason)
|
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
|
// 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
|
// to continue with an alternative route. This is indicated by the boolean
|
||||||
// return value.
|
// return value.
|
||||||
func (r *ChannelRouter) processSendError(rt *route.Route, sendErr error) (bool,
|
func (r *ChannelRouter) processSendError(paymentID uint64, rt *route.Route,
|
||||||
channeldb.FailureReason) {
|
sendErr error) (bool, channeldb.FailureReason) {
|
||||||
|
|
||||||
if sendErr == htlcswitch.ErrUnreadableFailureMessage {
|
if sendErr == htlcswitch.ErrUnreadableFailureMessage {
|
||||||
log.Tracef("Unreadable failure when sending htlc")
|
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
|
// If an internal, non-forwarding error occurred, we can stop
|
||||||
// trying.
|
// trying.
|
||||||
@ -1926,7 +1928,7 @@ func (r *ChannelRouter) processSendError(rt *route.Route, sendErr error) (bool,
|
|||||||
failureSourceIdx)
|
failureSourceIdx)
|
||||||
|
|
||||||
return r.cfg.MissionControl.ReportPaymentFail(
|
return r.cfg.MissionControl.ReportPaymentFail(
|
||||||
rt, &failureSourceIdx, failureMessage,
|
paymentID, rt, &failureSourceIdx, failureMessage,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user