routing: stop tracking totalAmount in paymentLifecycle

This commit removes the field `totalAmount` from `paymentLifecycle` and
only reads it from the channeldb payment.
This commit is contained in:
yyforyongyu
2022-06-10 01:34:22 +08:00
parent e3bc4f4cc9
commit 8d49dfb07e
5 changed files with 33 additions and 21 deletions

View File

@@ -667,9 +667,8 @@ func (r *ChannelRouter) Start() error {
// also set a zero fee limit, as no more routes should
// be tried.
_, _, err := r.sendPayment(
payment.Info.Value, 0,
payment.Info.PaymentIdentifier, 0, paySession,
shardTracker,
0, payment.Info.PaymentIdentifier, 0,
paySession, shardTracker,
)
if err != nil {
log.Errorf("Resuming payment %v failed: %v.",
@@ -2048,7 +2047,7 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte,
// Since this is the first time this payment is being made, we pass nil
// for the existing attempt.
return r.sendPayment(
payment.Amount, payment.FeeLimit, payment.Identifier(),
payment.FeeLimit, payment.Identifier(),
payment.PayAttemptTimeout, paySession, shardTracker,
)
}
@@ -2071,7 +2070,7 @@ func (r *ChannelRouter) SendPaymentAsync(payment *LightningPayment) error {
spewPayment(payment))
_, _, err := r.sendPayment(
payment.Amount, payment.FeeLimit, payment.Identifier(),
payment.FeeLimit, payment.Identifier(),
payment.PayAttemptTimeout, paySession, shardTracker,
)
if err != nil {
@@ -2335,9 +2334,9 @@ func (r *ChannelRouter) sendToRoute(htlcHash lntypes.Hash, rt *route.Route,
// carry out its execution. After restarts it is safe, and assumed, that the
// router will call this method for every payment still in-flight according to
// the ControlTower.
func (r *ChannelRouter) sendPayment(
totalAmt, feeLimit lnwire.MilliSatoshi, identifier lntypes.Hash,
timeout time.Duration, paySession PaymentSession,
func (r *ChannelRouter) sendPayment(feeLimit lnwire.MilliSatoshi,
identifier lntypes.Hash, timeout time.Duration,
paySession PaymentSession,
shardTracker shards.ShardTracker) ([32]byte, *route.Route, error) {
// We'll also fetch the current block height so we can properly
@@ -2351,7 +2350,6 @@ func (r *ChannelRouter) sendPayment(
// can resume the payment from the current state.
p := &paymentLifecycle{
router: r,
totalAmount: totalAmt,
feeLimit: feeLimit,
identifier: identifier,
paySession: paySession,