| 597 | } |
| 598 | |
| 599 | static void init_linear_network(const tal_t *ctx, |
| 600 | const struct pay_parameters *params, |
| 601 | struct graph **graph, double **arc_prob_cost, |
| 602 | double **arc_fee_cost, |
| 603 | double **arc_delay_cost, |
| 604 | s64 **arc_capacity) |
| 605 | { |
| 606 | const struct gossmap *gossmap = params->rq->gossmap; |
| 607 | const size_t max_num_chans = gossmap_max_chan_idx(gossmap); |
| 608 | const size_t max_num_arcs = max_num_chans * ARCS_PER_CHANNEL; |
| 609 | const size_t max_num_nodes = gossmap_max_node_idx(gossmap); |
| 610 | |
| 611 | *graph = graph_new(ctx, max_num_nodes, max_num_arcs, ARC_DUAL_BITOFF); |
| 612 | *arc_prob_cost = tal_arr(ctx, double, max_num_arcs); |
| 613 | for (size_t i = 0; i < max_num_arcs; ++i) |
| 614 | (*arc_prob_cost)[i] = DBL_MAX; |
| 615 | |
| 616 | *arc_fee_cost = tal_arr(ctx, double, max_num_arcs); |
| 617 | for (size_t i = 0; i < max_num_arcs; ++i) |
| 618 | (*arc_fee_cost)[i] = DBL_MAX; |
| 619 | |
| 620 | *arc_delay_cost = tal_arr(ctx, double, max_num_arcs); |
| 621 | for (size_t i = 0; i < max_num_arcs; ++i) |
| 622 | (*arc_delay_cost)[i] = DBL_MAX; |
| 623 | |
| 624 | *arc_capacity = tal_arrz(ctx, s64, max_num_arcs); |
| 625 | |
| 626 | for(struct gossmap_node *node = gossmap_first_node(gossmap); |
| 627 | node; |
| 628 | node=gossmap_next_node(gossmap,node)) |
| 629 | { |
| 630 | const u32 node_id = gossmap_node_idx(gossmap,node); |
| 631 | |
| 632 | for(size_t j=0;j<node->num_chans;++j) |
| 633 | { |
| 634 | int half; |
| 635 | const struct gossmap_chan *c = gossmap_nth_chan(gossmap, |
| 636 | node, j, &half); |
| 637 | |
| 638 | if (!channel_is_available(params->rq, c, half)) |
| 639 | continue; |
| 640 | |
| 641 | /* If a channel insists on more than our total, remove it */ |
| 642 | if (amount_msat_less(params->amount, gossmap_chan_htlc_min(c, half))) |
| 643 | continue; |
| 644 | |
| 645 | const u32 chan_id = gossmap_chan_idx(gossmap, c); |
| 646 | |
| 647 | const struct gossmap_node *next = gossmap_nth_node(gossmap, |
| 648 | c,!half); |
| 649 | |
| 650 | const u32 next_id = gossmap_node_idx(gossmap,next); |
| 651 | |
| 652 | if(node_id==next_id) |
| 653 | continue; |
| 654 | |
| 655 | // `cost` is the word normally used to denote cost per |
| 656 | // unit of flow in the context of MCF. |
no test coverage detected