MCPcopy Create free account
hub / github.com/ElementsProject/lightning / squash_flows

Function squash_flows

plugins/askrene/child/refine.c:653–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653void squash_flows(const tal_t *ctx, struct route_query *rq,
654 struct flow ***flows)
655{
656 asort(*flows, tal_count(*flows), cmppath_flows, NULL);
657 for (size_t i = 0; i < tal_count(*flows); i++) {
658 struct flow *flow = (*flows)[i];
659
660 /* same path? We merge */
661 while (i + 1 < tal_count(*flows) &&
662 cmppath_flows(&flow, &(*flows)[i+1], NULL) == 0) {
663 struct amount_msat combined, max = flow_max_deliverable(rq, flow);
664
665 if (!amount_msat_add(&combined, flow->delivers, (*flows)[i+1]->delivers))
666 abort();
667 /* do we break any HTLC max limits */
668 if (amount_msat_greater(combined, max))
669 break;
670 flow->delivers = combined;
671 del_flow_from_arr(flows, i+1);
672 }
673 }
674}
675
676double flows_probability(const tal_t *ctx, struct route_query *rq,
677 struct flow ***flows)

Callers 1

linear_routesFunction · 0.85

Calls 6

cmppath_flowsFunction · 0.85
flow_max_deliverableFunction · 0.85
amount_msat_addFunction · 0.85
abortFunction · 0.85
amount_msat_greaterFunction · 0.85
del_flow_from_arrFunction · 0.85

Tested by

no test coverage detected