multi: move payment state handling into MPPayment

This commit moves the struct `paymentState` used in `routing` into
`channeldb` and replaces it with `MPPaymentState`. In the following
commit we'd see the benefit, that we don't need to pass variables back
and forth between the two packages. More importantly, this state is put
closer to its origin, and is strictly updated whenever a payment is read
from disk. This approach is less error-prone comparing to the previous
one, which both the `payment` and `paymentState` need to be updated at
the same time to make sure the data stay consistant in a parallel
environment.
This commit is contained in:
yyforyongyu authored and Olaoluwa Osuntokun committed 2023-10-06 16:38:31 -07:00
1 parent bf99e42f8e
commit 52c00e8cc4
7 files changed
+281 -407

No files matched your search

+5
View File
@@ -518,6 +518,11 @@ func (m *mockControlTowerOld) fetchPayment(phash lntypes.Hash) (
// Return a copy of the current attempts.
mp.HTLCs = append(mp.HTLCs, p.attempts...)
if err := mp.SetState(); err != nil {
return nil, err
}
return mp, nil
}