mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-02 15:33:32 +02:00
channeldb+routing: apply method Terminated
to decide a payment's terminal state
This commit applies the new method `Terminated`. A side effect from using this method is, we can now save one query `fetchPayment` inside `FetchInFlightPayments`.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
fac6044501
commit
c175386c4d
@@ -722,21 +722,16 @@ func (p *PaymentControl) FetchInFlightPayments() ([]*MPPayment, error) {
|
||||
return fmt.Errorf("non bucket element")
|
||||
}
|
||||
|
||||
// If the status is not InFlight, we can return early.
|
||||
paymentStatus, err := fetchPaymentStatus(bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if paymentStatus != StatusInFlight {
|
||||
return nil
|
||||
}
|
||||
|
||||
p, err := fetchPayment(bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Skip the payment if it's terminated.
|
||||
if p.Terminated() {
|
||||
return nil
|
||||
}
|
||||
|
||||
inFlights = append(inFlights, p)
|
||||
return nil
|
||||
})
|
||||
|
Reference in New Issue
Block a user