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. * */
| 128 | * success provided that there are no other flows in the current MPP flow set. |
| 129 | * */ |
| 130 | double flow_probability(const struct flow *flow, |
| 131 | const struct route_query *rq) |
| 132 | { |
| 133 | const size_t pathlen = tal_count(flow->path); |
| 134 | struct amount_msat spend = flow->delivers; |
| 135 | double prob = 1.0; |
| 136 | |
| 137 | for (int i = (int)pathlen - 1; i >= 0; i--) { |
| 138 | const struct half_chan *h = flow_edge(flow, i); |
| 139 | struct short_channel_id_dir scidd; |
| 140 | scidd.scid = gossmap_chan_scid(rq->gossmap, flow->path[i]); |
| 141 | scidd.dir = flow->dirs[i]; |
| 142 | |
| 143 | prob *= edge_probability(rq, &scidd, spend); |
| 144 | |
| 145 | if (!amount_msat_add_fee(&spend, h->base_fee, |
| 146 | h->proportional_fee)) { |
| 147 | child_err("Could not add fee %u/%u to amount %s in %i/%zu", |
| 148 | h->base_fee, h->proportional_fee, |
| 149 | fmt_amount_msat(tmpctx, spend), |
| 150 | i, pathlen); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | return prob; |
| 155 | } |
| 156 | |
| 157 | u64 flow_delay(const struct flow *flow) |
| 158 | { |
no test coverage detected