mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-12 18:01:23 +02:00
routing: add new method reloadInflightAttempts
To shorten the method `resumePayment` and make each step more clear.
This commit is contained in:
parent
f96eb50ca8
commit
966cfccb94
@ -175,20 +175,11 @@ func (p *paymentLifecycle) resumePayment(ctx context.Context) ([32]byte,
|
|||||||
// If we had any existing attempts outstanding, we'll start by spinning
|
// If we had any existing attempts outstanding, we'll start by spinning
|
||||||
// up goroutines that'll collect their results and deliver them to the
|
// up goroutines that'll collect their results and deliver them to the
|
||||||
// lifecycle loop below.
|
// lifecycle loop below.
|
||||||
payment, err := p.router.cfg.Control.FetchPayment(p.identifier)
|
payment, err := p.reloadInflightAttempts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return [32]byte{}, nil, err
|
return [32]byte{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range payment.InFlightHTLCs() {
|
|
||||||
a := a
|
|
||||||
|
|
||||||
log.Infof("Resuming HTLC attempt %v for payment %v",
|
|
||||||
a.AttemptID, p.identifier)
|
|
||||||
|
|
||||||
p.resultCollector(&a)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the payment status.
|
// Get the payment status.
|
||||||
status := payment.GetStatus()
|
status := payment.GetStatus()
|
||||||
|
|
||||||
@ -1084,3 +1075,24 @@ func marshallError(sendError error, time time.Time) *channeldb.HTLCFailInfo {
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reloadInflightAttempts is called when the payment lifecycle is resumed after
|
||||||
|
// a restart. It reloads all inflight attempts from the control tower and
|
||||||
|
// collects the results of the attempts that have been sent before.
|
||||||
|
func (p *paymentLifecycle) reloadInflightAttempts() (DBMPPayment, error) {
|
||||||
|
payment, err := p.router.cfg.Control.FetchPayment(p.identifier)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range payment.InFlightHTLCs() {
|
||||||
|
a := a
|
||||||
|
|
||||||
|
log.Infof("Resuming HTLC attempt %v for payment %v",
|
||||||
|
a.AttemptID, p.identifier)
|
||||||
|
|
||||||
|
p.resultCollector(&a)
|
||||||
|
}
|
||||||
|
|
||||||
|
return payment, nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user