routing/payment_lifecycle: move Fail call to payment loop
In our quest to move calls to the ControlTower into the main payment lifecycle loop, we move the edge case of a too long route out of createNewPaymentAttempt.
This commit is contained in:
parent
3620721391
commit
4485e8261f
@ -117,9 +117,27 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
|
|||||||
firstHop, htlcAdd, attempt, err := p.createNewPaymentAttempt(
|
firstHop, htlcAdd, attempt, err := p.createNewPaymentAttempt(
|
||||||
rt,
|
rt,
|
||||||
)
|
)
|
||||||
|
// With SendToRoute, it can happen that the route exceeds protocol
|
||||||
|
// constraints. Mark the payment as failed with an internal error.
|
||||||
|
if err == route.ErrMaxRouteHopsExceeded ||
|
||||||
|
err == sphinx.ErrMaxRoutingInfoSizeExceeded {
|
||||||
|
|
||||||
|
log.Debugf("Invalid route provided for payment %x: %v",
|
||||||
|
p.paymentHash, err)
|
||||||
|
|
||||||
|
controlErr := p.router.cfg.Control.Fail(
|
||||||
|
p.paymentHash, channeldb.FailureReasonError,
|
||||||
|
)
|
||||||
|
if controlErr != nil {
|
||||||
|
return [32]byte{}, nil, controlErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In any case, don't continue if there is an error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, nil, err
|
return [32]byte{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.attempt = attempt
|
p.attempt = attempt
|
||||||
|
|
||||||
// Before sending this HTLC to the switch, we checkpoint the
|
// Before sending this HTLC to the switch, we checkpoint the
|
||||||
@ -326,24 +344,6 @@ func (p *paymentLifecycle) createNewPaymentAttempt(rt *route.Route) (
|
|||||||
onionBlob, c, err := generateSphinxPacket(
|
onionBlob, c, err := generateSphinxPacket(
|
||||||
rt, p.paymentHash[:], sessionKey,
|
rt, p.paymentHash[:], sessionKey,
|
||||||
)
|
)
|
||||||
|
|
||||||
// With SendToRoute, it can happen that the route exceeds protocol
|
|
||||||
// constraints. Mark the payment as failed with an internal error.
|
|
||||||
if err == route.ErrMaxRouteHopsExceeded ||
|
|
||||||
err == sphinx.ErrMaxRoutingInfoSizeExceeded {
|
|
||||||
|
|
||||||
log.Debugf("Invalid route provided for payment %x: %v",
|
|
||||||
p.paymentHash, err)
|
|
||||||
|
|
||||||
controlErr := p.router.cfg.Control.Fail(
|
|
||||||
p.paymentHash, channeldb.FailureReasonError,
|
|
||||||
)
|
|
||||||
if controlErr != nil {
|
|
||||||
return lnwire.ShortChannelID{}, nil, nil, controlErr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In any case, don't continue if there is an error.
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return lnwire.ShortChannelID{}, nil, nil, err
|
return lnwire.ShortChannelID{}, nil, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user