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

Function flow_probability

plugins/askrene/child/flow.c:130–155  ·  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

128 * success provided that there are no other flows in the current MPP flow set.
129 * */
130double 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
157u64 flow_delay(const struct flow *flow)
158{

Callers 2

convert_flows_to_routesFunction · 0.70
flows_probabilityFunction · 0.70

Calls 6

gossmap_chan_scidFunction · 0.85
amount_msat_add_feeFunction · 0.85
child_errFunction · 0.85
flow_edgeFunction · 0.70
edge_probabilityFunction · 0.70
fmt_amount_msatFunction · 0.50

Tested by

no test coverage detected