Given a flow in the residual network, build a set of payment flows in the * gossmap that corresponds to this flow. */
| 1265 | /* Given a flow in the residual network, build a set of payment flows in the |
| 1266 | * gossmap that corresponds to this flow. */ |
| 1267 | static struct flow ** |
| 1268 | get_flow_paths(const tal_t *ctx, const struct gossmap *gossmap, |
| 1269 | const bitmap *disabled, |
| 1270 | |
| 1271 | // chan_extra_map cannot be const because we use it to keep |
| 1272 | // track of htlcs and in_flight sats. |
| 1273 | struct chan_extra_map *chan_extra_map, |
| 1274 | const struct linear_network *linear_network, |
| 1275 | const struct residual_network *residual_network, |
| 1276 | |
| 1277 | // how many msats in excess we paid for not having msat accuracy |
| 1278 | // in the MCF solver |
| 1279 | struct amount_msat excess, |
| 1280 | const double base_probability, |
| 1281 | |
| 1282 | // error message |
| 1283 | char **fail) |
| 1284 | { |
| 1285 | tal_t *this_ctx = tal(ctx,tal_t); |
| 1286 | struct flow **flows = tal_arr(ctx,struct flow*,0); |
| 1287 | |
| 1288 | assert(amount_msat_less(excess, AMOUNT_MSAT(1000))); |
| 1289 | |
| 1290 | const size_t max_num_chans = gossmap_max_chan_idx(gossmap); |
| 1291 | struct chan_flow *chan_flow = tal_arrz(this_ctx,struct chan_flow,max_num_chans); |
| 1292 | |
| 1293 | const size_t max_num_nodes = gossmap_max_node_idx(gossmap); |
| 1294 | s64 *balance = tal_arrz(this_ctx,s64,max_num_nodes); |
| 1295 | |
| 1296 | const struct gossmap_chan **prev_chan |
| 1297 | = tal_arr(this_ctx,const struct gossmap_chan *,max_num_nodes); |
| 1298 | |
| 1299 | |
| 1300 | int *prev_dir = tal_arr(this_ctx,int,max_num_nodes); |
| 1301 | u32 *prev_idx = tal_arr(this_ctx,u32,max_num_nodes); |
| 1302 | |
| 1303 | if (!chan_flow || !balance || !prev_chan || !prev_idx || !prev_dir) { |
| 1304 | if (fail) |
| 1305 | *fail = tal_fmt(ctx, "bad allocation"); |
| 1306 | goto function_fail; |
| 1307 | } |
| 1308 | |
| 1309 | // Convert the arc based residual network flow into a flow in the |
| 1310 | // directed channel network. |
| 1311 | // Compute balance on the nodes. |
| 1312 | for(u32 n = 0;n<max_num_nodes;++n) |
| 1313 | { |
| 1314 | for(struct arc arc = node_adjacency_begin(linear_network,n); |
| 1315 | !node_adjacency_end(arc); |
| 1316 | arc = node_adjacency_next(linear_network,arc)) |
| 1317 | { |
| 1318 | if(arc_is_dual(arc)) |
| 1319 | continue; |
| 1320 | u32 m = arc_head(linear_network,arc); |
| 1321 | s64 flow = get_arc_flow(residual_network,arc); |
| 1322 | u32 chanidx; |
| 1323 | int chandir; |
| 1324 |
no test coverage detected