| 914 | } |
| 915 | |
| 916 | void gossmap_remove_localmods(struct gossmap *map, |
| 917 | const struct gossmap_localmods *localmods) |
| 918 | { |
| 919 | size_t n = tal_count(localmods->mods); |
| 920 | |
| 921 | assert(map->local == localmods->local); |
| 922 | |
| 923 | for (size_t i = 0; i < n; i++) { |
| 924 | const struct localmod *mod = &localmods->mods[i]; |
| 925 | struct gossmap_chan *chan = gossmap_find_chan(map, &mod->scid); |
| 926 | |
| 927 | /* If that's a local channel, remove it now. */ |
| 928 | if (chan->cann_off >= map->map_size) { |
| 929 | gossmap_remove_chan(map, chan); |
| 930 | } else { |
| 931 | /* Restore (keep nodeidx). */ |
| 932 | for (size_t h = 0; h < 2; h++) { |
| 933 | u32 nodeidx; |
| 934 | if (!mod->updates_set[h]) |
| 935 | continue; |
| 936 | |
| 937 | nodeidx = chan->half[h].nodeidx; |
| 938 | chan->half[h] = mod->orig[h]; |
| 939 | chan->half[h].nodeidx = nodeidx; |
| 940 | chan->cupdate_off[h] = mod->orig_cupdate_off[h]; |
| 941 | } |
| 942 | } |
| 943 | } |
| 944 | map->local = NULL; |
| 945 | } |
| 946 | |
| 947 | bool gossmap_refresh(struct gossmap *map, size_t *num_rejected) |
| 948 | { |