| 1391 | } |
| 1392 | |
| 1393 | void gossmap_manage_new_block(struct gossmap_manage *gm, u32 new_blockheight) |
| 1394 | { |
| 1395 | u64 idx; |
| 1396 | |
| 1397 | for (struct pending_cannounce *pca = uintmap_first(&gm->early_ann_map.map, &idx); |
| 1398 | pca != NULL; |
| 1399 | pca = uintmap_after(&gm->early_ann_map.map, &idx)) { |
| 1400 | struct short_channel_id scid; |
| 1401 | scid.u64 = idx; |
| 1402 | |
| 1403 | /* Stop when we are at unreachable heights */ |
| 1404 | if (!is_scid_depth_announceable(scid, new_blockheight)) |
| 1405 | break; |
| 1406 | |
| 1407 | map_del(&gm->early_ann_map, scid); |
| 1408 | |
| 1409 | if (!map_add(&gm->pending_ann_map, scid, pca)) { |
| 1410 | /* Already pending? Ignore */ |
| 1411 | tal_free(pca); |
| 1412 | continue; |
| 1413 | } |
| 1414 | |
| 1415 | status_debug("gossmap_manage: new block, adding %s to pending...", |
| 1416 | fmt_short_channel_id(tmpctx, scid)); |
| 1417 | |
| 1418 | /* Ask lightningd about this scid: see |
| 1419 | * gossmap_manage_handle_get_txout_reply */ |
| 1420 | daemon_conn_send(gm->daemon->master, |
| 1421 | take(towire_gossipd_get_txout(NULL, scid))); |
| 1422 | } |
| 1423 | |
| 1424 | for (size_t i = 0; i < tal_count(gm->dying_channels); i++) { |
| 1425 | struct gossmap *gossmap; |
| 1426 | |
| 1427 | if (gm->dying_channels[i].deadline > new_blockheight) |
| 1428 | continue; |
| 1429 | |
| 1430 | /* Refresh gossmap each time in case we move things in the loop: |
| 1431 | * in particular, we might move a node_announcement twice! */ |
| 1432 | gossmap = gossmap_manage_get_gossmap(gm); |
| 1433 | kill_spent_channel(gm, gossmap, gm->dying_channels[i].scid); |
| 1434 | gossip_store_del(gm->gs, |
| 1435 | gm->dying_channels[i].gossmap_offset, |
| 1436 | WIRE_GOSSIP_STORE_CHAN_DYING); |
| 1437 | tal_arr_remove(&gm->dying_channels, i); |
| 1438 | /* Don't skip next one! */ |
| 1439 | i--; |
| 1440 | } |
| 1441 | } |
| 1442 | |
| 1443 | void gossmap_manage_channel_spent(struct gossmap_manage *gm, |
| 1444 | u32 blockheight, |
no test coverage detected