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

Function gossmap_load_

common/gossmap.c:1408–1448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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