mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-30 17:50:58 +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
|
||||
// up goroutines that'll collect their results and deliver them to the
|
||||
// lifecycle loop below.
|
||||
payment, err := p.router.cfg.Control.FetchPayment(p.identifier)
|
||||
payment, err := p.reloadInflightAttempts()
|
||||
if err != nil {
|
||||
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.
|
||||
status := payment.GetStatus()
|
||||
|
||||
@ -1084,3 +1075,24 @@ func marshallError(sendError error, time time.Time) *channeldb.HTLCFailInfo {
|
||||
|
||||
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