@@ -323,37 +323,6 @@ void layer_add_localmods(const struct layer *layer,
323323 const struct local_channel * lc ;
324324 struct local_channel_hash_iter lcit ;
325325
326- /* First, disable all channels into blocked nodes (local updates
327- * can add new ones)! */
328- for (size_t i = 0 ; i < tal_count (layer -> disabled ); i ++ ) {
329- struct route_exclusion ex = layer -> disabled [i ];
330-
331- /* Disable all channels of excluded nodes. */
332- if (ex .type == EXCLUDE_NODE ) {
333- const struct gossmap_node * node ;
334-
335- node = gossmap_find_node (gossmap , & ex .u .node_id );
336- if (!node )
337- continue ;
338- for (size_t n = 0 ; n < node -> num_chans ; n ++ ) {
339- struct short_channel_id scid ;
340- struct gossmap_chan * c ;
341- int dir ;
342- c = gossmap_nth_chan (gossmap , node , n , & dir );
343- scid = gossmap_chan_scid (gossmap , c );
344-
345- /* Disabled zero-capacity on incoming */
346- gossmap_local_updatechan (
347- localmods , scid , AMOUNT_MSAT (0 ),
348- AMOUNT_MSAT (0 ), 0 , 0 , 0 , false, !dir );
349- }
350- } else {
351- gossmap_local_updatechan (
352- localmods , ex .u .chan_id .scid , AMOUNT_MSAT (0 ),
353- AMOUNT_MSAT (0 ), 0 , 0 , 0 , false, ex .u .chan_id .dir );
354- }
355- }
356-
357326 for (lc = local_channel_hash_first (layer -> local_channels , & lcit );
358327 lc ;
359328 lc = local_channel_hash_next (layer -> local_channels , & lcit )) {
@@ -489,3 +458,56 @@ void layer_memleak_mark(struct askrene *askrene, struct htable *memtable)
489458 memleak_scan_htable (memtable , & l -> local_channels -> raw );
490459 }
491460}
461+
462+ static void set_channel_bit (bitmap * bm , const struct gossmap * gossmap ,
463+ const struct short_channel_id_dir * scidd )
464+ {
465+ const struct gossmap_chan * chan =
466+ gossmap_find_chan (gossmap , & scidd -> scid );
467+
468+ if (!chan )
469+ return ;
470+
471+ bitmap_set_bit (bm , gossmap_chan_idx (gossmap , chan ) * 2 + scidd -> dir );
472+ }
473+
474+ static void set_node_channels_bit (bitmap * bm , const struct gossmap * gossmap ,
475+ const struct node_id * node_id )
476+ {
477+ const struct gossmap_node * node = gossmap_find_node (gossmap , node_id );
478+ for (size_t k = 0 ; k < node -> num_chans ; k ++ ) {
479+ int half ;
480+ const struct gossmap_chan * chan =
481+ gossmap_nth_chan (gossmap , node , k , & half );
482+
483+ bitmap_set_bit (bm , gossmap_chan_idx (gossmap , chan ) * 2 + half );
484+ bitmap_set_bit (bm , gossmap_chan_idx (gossmap , chan ) * 2 + !half );
485+ }
486+ }
487+
488+ bitmap * tal_get_disabled_bitmap (const tal_t * ctx , struct route_query * rq )
489+ {
490+
491+ bitmap * disabled = tal_arrz (
492+ ctx , bitmap , 2 * BITMAP_NWORDS (gossmap_max_chan_idx (rq -> gossmap )));
493+
494+ if (!disabled )
495+ return NULL ;
496+
497+ /* Disable every channel in the list of disabled scids. */
498+ for (size_t i = 0 ; i < tal_count (rq -> layers ); i ++ ) {
499+ const struct layer * l = rq -> layers [i ];
500+
501+ for (size_t j = 0 ; j < tal_count (l -> disabled ); j ++ ) {
502+ const struct route_exclusion * ex = & l -> disabled [j ];
503+
504+ if (ex -> type == EXCLUDE_CHANNEL )
505+ set_channel_bit (disabled , rq -> gossmap ,
506+ & ex -> u .chan_id );
507+ else
508+ set_node_channels_bit (disabled , rq -> gossmap ,
509+ & ex -> u .node_id );
510+ }
511+ }
512+ return disabled ;
513+ }
0 commit comments