mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-21 06:12:38 +02:00
routing: add newPaymentLifecycle
to properly init lifecycle
This commit adds a new method to properly init a payment lifecycle so we can easily see the default values used here.
This commit is contained in:
parent
34d0e5d4c5
commit
a6be939bfa
@ -31,6 +31,31 @@ type paymentLifecycle struct {
|
|||||||
currentHeight int32
|
currentHeight int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newPaymentLifecycle initiates a new payment lifecycle and returns it.
|
||||||
|
func newPaymentLifecycle(r *ChannelRouter, feeLimit lnwire.MilliSatoshi,
|
||||||
|
identifier lntypes.Hash, paySession PaymentSession,
|
||||||
|
shardTracker shards.ShardTracker, timeout time.Duration,
|
||||||
|
currentHeight int32) *paymentLifecycle {
|
||||||
|
|
||||||
|
p := &paymentLifecycle{
|
||||||
|
router: r,
|
||||||
|
feeLimit: feeLimit,
|
||||||
|
identifier: identifier,
|
||||||
|
paySession: paySession,
|
||||||
|
shardTracker: shardTracker,
|
||||||
|
currentHeight: currentHeight,
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a timeout is specified, create a timeout channel. If no timeout is
|
||||||
|
// specified, the channel is left nil and will never abort the payment
|
||||||
|
// loop.
|
||||||
|
if timeout != 0 {
|
||||||
|
p.timeoutChan = time.After(timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// calcFeeBudget returns the available fee to be used for sending HTLC
|
// calcFeeBudget returns the available fee to be used for sending HTLC
|
||||||
// attempts.
|
// attempts.
|
||||||
func (p *paymentLifecycle) calcFeeBudget(
|
func (p *paymentLifecycle) calcFeeBudget(
|
||||||
|
@ -2415,21 +2415,10 @@ func (r *ChannelRouter) sendPayment(feeLimit lnwire.MilliSatoshi,
|
|||||||
|
|
||||||
// Now set up a paymentLifecycle struct with these params, such that we
|
// Now set up a paymentLifecycle struct with these params, such that we
|
||||||
// can resume the payment from the current state.
|
// can resume the payment from the current state.
|
||||||
p := &paymentLifecycle{
|
p := newPaymentLifecycle(
|
||||||
router: r,
|
r, feeLimit, identifier, paySession,
|
||||||
feeLimit: feeLimit,
|
shardTracker, timeout, currentHeight,
|
||||||
identifier: identifier,
|
)
|
||||||
paySession: paySession,
|
|
||||||
shardTracker: shardTracker,
|
|
||||||
currentHeight: currentHeight,
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a timeout is specified, create a timeout channel. If no timeout is
|
|
||||||
// specified, the channel is left nil and will never abort the payment
|
|
||||||
// loop.
|
|
||||||
if timeout != 0 {
|
|
||||||
p.timeoutChan = time.After(timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.resumePayment()
|
return p.resumePayment()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user