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

Function load_gossip_store

common/gossmap.c:939–970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937}
938
939static bool load_gossip_store(struct gossmap *map,
940 void (*dyingcb)(struct short_channel_id scid,
941 u32 blockheight,
942 u64 offset,
943 void *cb_arg),
944 void *cb_arg,
945 bool must_be_clean)
946{
947 bool updated;
948
949 map->map_size = lseek(map->fd, 0, SEEK_END);
950 map->local_announces = NULL;
951 map->local_updates = NULL;
952
953 /* If this fails, we fall back to read */
954 map->mmap = mmap(NULL, map->map_size, PROT_READ, MAP_SHARED, map->fd, 0);
955 if (map->mmap == MAP_FAILED)
956 map->mmap = NULL;
957
958 /* We only support major version 0 */
959 if (GOSSIP_STORE_MAJOR_VERSION(map_u8(map, 0)) != 0) {
960 map->logcb(map->cbarg, LOG_BROKEN,
961 "Unknown gossip_store version %u", map_u8(map, 0));
962 errno = EINVAL;
963 return false;
964 }
965
966 init_map_structs(map);
967
968 map->map_end = 1;
969 return map_catchup(map, dyingcb, cb_arg, must_be_clean, &updated);
970}
971
972static void destroy_map(struct gossmap *map)
973{

Callers 1

gossmap_load_Function · 0.85

Calls 3

map_u8Function · 0.85
init_map_structsFunction · 0.85
map_catchupFunction · 0.85

Tested by

no test coverage detected