@@ -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.
@@ -568,7 +577,7 @@ static void init_linear_network(const tal_t *ctx,
568577 const struct gossmap_chan * c = gossmap_nth_chan (gossmap ,
569578 node , j , & half );
570579
571- if (!gossmap_chan_set ( c , half ) || ! c -> half [ half ]. enabled )
580+ if (!channel_is_available ( params -> rq , c , half ))
572581 continue ;
573582
574583 /* If a channel insists on more than our total, remove it */
@@ -644,7 +653,7 @@ struct chan_flow
644653 * */
645654static struct node find_path_or_cycle (
646655 const tal_t * working_ctx ,
647- const struct gossmap * gossmap ,
656+ const struct route_query * rq ,
648657 const struct chan_flow * chan_flow ,
649658 const struct node source ,
650659 const s64 * balance ,
@@ -653,6 +662,7 @@ static struct node find_path_or_cycle(
653662 int * prev_dir ,
654663 u32 * prev_idx )
655664{
665+ const struct gossmap * gossmap = rq -> gossmap ;
656666 const size_t max_num_nodes = gossmap_max_node_idx (gossmap );
657667 bitmap * visited =
658668 tal_arrz (working_ctx , bitmap , BITMAP_NWORDS (max_num_nodes ));
@@ -671,7 +681,7 @@ static struct node find_path_or_cycle(
671681 const struct gossmap_chan * c =
672682 gossmap_nth_chan (gossmap , cur , i , & dir );
673683
674- if (!gossmap_chan_set ( c , dir ) || ! c -> half [ dir ]. enabled )
684+ if (!channel_is_available ( rq , c , dir ))
675685 continue ;
676686
677687 const u32 c_idx = gossmap_chan_idx (gossmap , c );
@@ -877,7 +887,7 @@ get_flow_paths(const tal_t *ctx,
877887 while (balance [source .idx ] < 0 ) {
878888 prev_chan [source .idx ] = NULL ;
879889 struct node sink = find_path_or_cycle (
880- working_ctx , params -> rq -> gossmap , chan_flow , source ,
890+ working_ctx , params -> rq , chan_flow , source ,
881891 balance , prev_chan , prev_dir , prev_idx );
882892
883893 if (balance [sink .idx ] > 0 )
@@ -1107,8 +1117,7 @@ static void init_linear_network_single_path(
11071117 gossmap_nth_chan (gossmap , node , j , & half );
11081118 struct amount_msat mincap , maxcap ;
11091119
1110- if (!gossmap_chan_set (c , half ) ||
1111- !c -> half [half ].enabled )
1120+ if (!channel_is_available (params -> rq , c , half ))
11121121 continue ;
11131122
11141123 /* If a channel cannot forward the total amount we don't
0 commit comments