@@ -319,6 +319,15 @@ static void set_capacity(s64 *capacity, u64 value, u64 *cap_on_capacity)
319319 * cap_on_capacity -= * capacity ;
320320}
321321
322+ /* Helper to check whether a channel is available */
323+ static bool channel_is_available (const struct route_query * rq ,
324+ const struct gossmap_chan * chan , const int dir )
325+ {
326+ const u32 c_idx = gossmap_chan_idx (rq -> gossmap , chan );
327+ return gossmap_chan_set (chan , dir ) && chan -> half [dir ].enabled &&
328+ !bitmap_test_bit (rq -> disabled_chans , c_idx * 2 + dir );
329+ }
330+
322331/* FIXME: unit test this */
323332/* The probability of forwarding a payment amount given a high and low liquidity
324333 * bounds.
@@ -563,7 +572,7 @@ static void init_linear_network(const tal_t *ctx,
563572 const struct gossmap_chan * c = gossmap_nth_chan (gossmap ,
564573 node , j , & half );
565574
566- if (!gossmap_chan_set ( c , half ) || ! c -> half [ half ]. enabled )
575+ if (!channel_is_available ( params -> rq , c , half ))
567576 continue ;
568577
569578 /* If a channel insists on more than our total, remove it */
@@ -639,7 +648,7 @@ struct chan_flow
639648 * */
640649static struct node find_path_or_cycle (
641650 const tal_t * working_ctx ,
642- const struct gossmap * gossmap ,
651+ const struct route_query * rq ,
643652 const struct chan_flow * chan_flow ,
644653 const struct node source ,
645654 const s64 * balance ,
@@ -648,6 +657,7 @@ static struct node find_path_or_cycle(
648657 int * prev_dir ,
649658 u32 * prev_idx )
650659{
660+ const struct gossmap * gossmap = rq -> gossmap ;
651661 const size_t max_num_nodes = gossmap_max_node_idx (gossmap );
652662 bitmap * visited =
653663 tal_arrz (working_ctx , bitmap , BITMAP_NWORDS (max_num_nodes ));
@@ -666,7 +676,7 @@ static struct node find_path_or_cycle(
666676 const struct gossmap_chan * c =
667677 gossmap_nth_chan (gossmap , cur , i , & dir );
668678
669- if (!gossmap_chan_set ( c , dir ) || ! c -> half [ dir ]. enabled )
679+ if (!channel_is_available ( rq , c , dir ))
670680 continue ;
671681
672682 const u32 c_idx = gossmap_chan_idx (gossmap , c );
@@ -872,7 +882,7 @@ get_flow_paths(const tal_t *ctx,
872882 while (balance [source .idx ] < 0 ) {
873883 prev_chan [source .idx ] = NULL ;
874884 struct node sink = find_path_or_cycle (
875- working_ctx , params -> rq -> gossmap , chan_flow , source ,
885+ working_ctx , params -> rq , chan_flow , source ,
876886 balance , prev_chan , prev_dir , prev_idx );
877887
878888 if (balance [sink .idx ] > 0 )
@@ -1101,8 +1111,7 @@ static void init_linear_network_single_path(
11011111 gossmap_nth_chan (gossmap , node , j , & half );
11021112 struct amount_msat mincap , maxcap ;
11031113
1104- if (!gossmap_chan_set (c , half ) ||
1105- !c -> half [half ].enabled )
1114+ if (!channel_is_available (params -> rq , c , half ))
11061115 continue ;
11071116
11081117 /* If a channel cannot forward the total amount we don't
0 commit comments