select_inchan_mpp * * @brief fallback in case select_inchan cannot find a *single* * channel capable of accepting the payment as a whole. * Also the main routehint-selector if we are completely unpublished * (i.e. all our channels are unpublished), since if we are completely * unpublished then the payer cannot fall back to just directly routing * to us. */
| 622 | * to us. |
| 623 | */ |
| 624 | static struct route_info **select_inchan_mpp(const tal_t *ctx, |
| 625 | struct lightningd *ld, |
| 626 | struct amount_msat amount_needed, |
| 627 | struct routehint_candidate |
| 628 | *candidates) |
| 629 | { |
| 630 | /* The total amount we have gathered for incoming channels. */ |
| 631 | struct amount_msat gathered; |
| 632 | /* Routehint array. */ |
| 633 | struct route_info **routehints; |
| 634 | |
| 635 | gathered = AMOUNT_MSAT(0); |
| 636 | routehints = tal_arr(ctx, struct route_info *, 0); |
| 637 | |
| 638 | /* Sort by rr_number, so we get fresh channels. */ |
| 639 | asort(candidates, tal_count(candidates), cmp_rr_number, ld); |
| 640 | for (size_t i = 0; i < tal_count(candidates); i++) { |
| 641 | if (amount_msat_greater_eq(gathered, amount_needed)) |
| 642 | break; |
| 643 | |
| 644 | /* Add to current routehints set. */ |
| 645 | if (!amount_msat_accumulate(&gathered, candidates[i].capacity)) { |
| 646 | log_broken(ld->log, |
| 647 | "Gathered channel capacity overflow: " |
| 648 | "%s + %s", |
| 649 | fmt_amount_msat(tmpctx, gathered), |
| 650 | fmt_amount_msat(tmpctx, candidates[i].capacity)); |
| 651 | continue; |
| 652 | } |
| 653 | tal_arr_expand(&routehints, |
| 654 | tal_dup(routehints, struct route_info, |
| 655 | candidates[i].r)); |
| 656 | /* Put to the back of the round-robin list */ |
| 657 | candidates[i].c->rr_number = ld->rr_counter++; |
| 658 | } |
| 659 | |
| 660 | return routehints; |
| 661 | } |
| 662 | |
| 663 | static struct route_info **select_inchan_all(const tal_t *ctx, |
| 664 | struct lightningd *ld, |
no test coverage detected