MCPcopy Create free account
hub / github.com/ElementsProject/lightning / gossmap_manage_get_gossmap

Function gossmap_manage_get_gossmap

gossipd/gossmap_manage.c:1535–1592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1533}
1534
1535struct gossmap *gossmap_manage_get_gossmap(struct gossmap_manage *gm)
1536{
1537 u64 map_used, map_size, written_len;
1538 bool has_mmap = gossmap_has_mmap(gm->raw_gossmap);
1539
1540 gossmap_refresh(gm->raw_gossmap);
1541
1542 /* Sanity check that we see everything we wrote. */
1543 map_used = gossmap_lengths(gm->raw_gossmap, &map_size);
1544 written_len = gossip_store_len_written(gm->gs);
1545
1546 if (map_size != written_len) {
1547 status_broken("gossmap size %"PRIu64" != written size %"PRIu64
1548 ": %s mmap!",
1549 map_size, written_len,
1550 has_mmap
1551 ? "disabling": "ALREADY DISABLED");
1552 gossmap_disable_mmap(gm->raw_gossmap);
1553 gossmap_refresh(gm->raw_gossmap);
1554
1555 /* Sanity check that we see everything we wrote. */
1556 map_used = gossmap_lengths(gm->raw_gossmap, &map_size);
1557 written_len = gossip_store_len_written(gm->gs);
1558 if (map_used != written_len || map_size != map_used)
1559 status_failed(STATUS_FAIL_INTERNAL_ERROR,
1560 "gossmap read inconsistent even after sync"
1561 " used=%"PRIu64" seen=%"PRIu64" written=%"PRIu64,
1562 map_used, map_size, written_len);
1563 } else if (map_size != map_used) {
1564 const u8 *remainder_fd;
1565
1566 remainder_fd = fetch_tail_fd(tmpctx,
1567 gossmap_fd(gm->raw_gossmap),
1568 map_used, map_size);
1569 status_broken("Gossmap failed to process entire gossip_store, %s mmap: "
1570 "at %"PRIu64" of %"PRIu64" remaining_fd=%s",
1571 has_mmap
1572 ? "disabling": "ALREADY DISABLED",
1573 map_used, map_size,
1574 tal_hex(tmpctx, remainder_fd));
1575 gossmap_disable_mmap(gm->raw_gossmap);
1576
1577 /* Try rewriting the last few records, syncing. */
1578 gossip_store_rewrite_end(gm->gs);
1579 gossmap_refresh(gm->raw_gossmap);
1580
1581 map_used = gossmap_lengths(gm->raw_gossmap, &map_size);
1582 if (map_size != map_used) {
1583 status_failed(STATUS_FAIL_INTERNAL_ERROR,
1584 "Gossmap map_used %"PRIu64" of %"PRIu64" with %"PRIu64" written",
1585 map_used, map_size, written_len);
1586 }
1587 }
1588
1589 /* Free up last_writes, since we've seen it on disk */
1590 gossip_store_writes_confirmed(gm->gs);
1591 return gm->raw_gossmap;
1592}

Calls 11

gossmap_has_mmapFunction · 0.85
gossmap_refreshFunction · 0.85
gossmap_lengthsFunction · 0.85
gossip_store_len_writtenFunction · 0.85
gossmap_disable_mmapFunction · 0.85
fetch_tail_fdFunction · 0.85
gossmap_fdFunction · 0.85
tal_hexFunction · 0.85
gossip_store_rewrite_endFunction · 0.85
status_failedFunction · 0.50

Tested by

no test coverage detected