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. * */
| 434 | * success provided that there are no other flows in the current MPP flow set. |
| 435 | * */ |
| 436 | double 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 | |
| 464 | function_fail: |
| 465 | return -1.; |
| 466 | } |
| 467 | |
| 468 | u64 flow_delay(const struct flow *flow) |
| 469 | { |