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

Function gossmap_load_

common/gossmap.c:1403–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1401}
1402
1403struct gossmap *gossmap_load_(const tal_t *ctx,
1404 const char *filename,
1405 u64 expected_len,
1406 void (*logcb)(void *cb_arg,
1407 enum log_level level,
1408 const char *fmt,
1409 ...),
1410 void (*dyingcb)(struct short_channel_id scid,
1411 u32 blockheight,
1412 u64 offset,
1413 void *cb_arg),
1414 void *cb_arg)
1415{
1416 map = tal(ctx, struct gossmap);
1417 map->generation = 0;
1418 map->fname = tal_strdup(map, filename);
1419 map->fd = open(map->fname, O_RDONLY);
1420 map->num_live = map->num_dead = 0;
1421 if (map->fd < 0)
1422 return tal_free(map);
1423 if (logcb)
1424 map->logcb = logcb;
1425 else
1426 map->logcb = log_stderr;
1427 map->cbarg = cb_arg;
1428 tal_add_destructor(map, destroy_map);
1429
1430 if (!load_gossip_store(map, dyingcb, cb_arg, expected_len != 0))
1431 return tal_free(map);
1432 if (expected_len != 0
1433 && (map->map_size != map->map_end
1434 || map->map_size != expected_len)) {
1435 logcb(cb_arg, LOG_BROKEN,
1436 "gossip_store only processed %"PRIu64
1437 " bytes of %"PRIu64" (expected %"PRIu64")",
1438 map->map_end, map->map_size, expected_len);
1439 return tal_free(map);
1440 }
1441 return map;
1442}
1443
1444void gossmap_node_get_id(const struct gossmap *map,
1445 const struct gossmap_node *node,

Callers

nothing calls this directly

Calls 2

tal_freeFunction · 0.85
load_gossip_storeFunction · 0.85

Tested by

no test coverage detected