mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pay: Compute the number of HTLCs needed after presplit correctly
We were counting the attempts including the root payment, which resulted in an off-by-one error with the `test_pay_low_max_htlcs` test. Counting the children of the root payment after the presplitter had a go is the correct way to do it, since at that time we only have one level in the tree, no need to recurse and potentially count ourselves.
This commit is contained in:
committed by
Rusty Russell
parent
d4def7e73a
commit
803c048a1f
@@ -3596,18 +3596,17 @@ static void adaptive_splitter_cb(struct adaptive_split_mod_data *d, struct payme
|
|||||||
* update our htlc_budget that we own exclusively from now
|
* update our htlc_budget that we own exclusively from now
|
||||||
* on. We do this by subtracting the number of payment
|
* on. We do this by subtracting the number of payment
|
||||||
* attempts an eventual presplitter has already performed. */
|
* attempts an eventual presplitter has already performed. */
|
||||||
struct payment_tree_result res;
|
int children = tal_count(p->children);
|
||||||
res = payment_collect_result(p);
|
|
||||||
d->htlc_budget = payment_max_htlcs(p);
|
d->htlc_budget = payment_max_htlcs(p);
|
||||||
if (res.attempts > d->htlc_budget) {
|
if (children > d->htlc_budget) {
|
||||||
p->abort = true;
|
p->abort = true;
|
||||||
return payment_fail(
|
return payment_fail(
|
||||||
p,
|
p,
|
||||||
"Cannot add %d HTLCs to our channels, we "
|
"Cannot add %d HTLCs to our channels, we "
|
||||||
"only have %d HTLCs available.",
|
"only have %d HTLCs available.",
|
||||||
res.attempts, d->htlc_budget);
|
children, d->htlc_budget);
|
||||||
}
|
}
|
||||||
d->htlc_budget -= res.attempts;
|
d->htlc_budget -= children;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->step == PAYMENT_STEP_ONION_PAYLOAD) {
|
if (p->step == PAYMENT_STEP_ONION_PAYLOAD) {
|
||||||
|
|||||||
Reference in New Issue
Block a user