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

Function flow_probability

plugins/renepay/flow.c:436–466  ·  view source on GitHub ↗

Helper function to find the success_prob for a single flow * * IMPORTANT: flow->success_prob is misleading, because that's the prob. of * success provided that there are no other flows in the current MPP flow set. * */

Source from the content-addressed store, hash-verified

434 * success provided that there are no other flows in the current MPP flow set.
435 * */
436double flow_probability(struct flow *flow, const struct gossmap *gossmap,
437 struct chan_extra_map *chan_extra_map,
438 bool compute_fees)
439{
440 assert(flow);
441 assert(gossmap);
442 assert(chan_extra_map);
443 const size_t pathlen = tal_count(flow->path);
444 struct amount_msat spend = flow->amount;
445 double prob = 1.0;
446
447 for (int i = (int)pathlen - 1; i >= 0; i--) {
448 const struct half_chan *h = flow_edge(flow, i);
449 const struct chan_extra_half *eh = get_chan_extra_half_by_chan(
450 gossmap, chan_extra_map, flow->path[i], flow->dirs[i]);
451
452 prob *= edge_probability(eh->known_min, eh->known_max,
453 eh->htlc_total, spend);
454
455 if (prob < 0)
456 goto function_fail;
457 if (compute_fees && !amount_msat_add_fee(&spend, h->base_fee,
458 h->proportional_fee))
459 goto function_fail;
460 }
461
462 return prob;
463
464function_fail:
465 return -1.;
466}
467
468u64 flow_delay(const struct flow *flow)
469{

Callers 3

get_routesFunction · 0.70
get_flow_pathsFunction · 0.70
test_flow_to_routeFunction · 0.50

Calls 4

amount_msat_add_feeFunction · 0.85
flow_edgeFunction · 0.70
edge_probabilityFunction · 0.70

Tested by 1

test_flow_to_routeFunction · 0.40