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

Function main

devtools/topology.c:247–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247int main(int argc, char *argv[])
248{
249 struct timemono tstart, tstop;
250 struct gossmap_node *n, *dst;
251 struct gossmap *map;
252 struct node_id dstid;
253 bool no_singles = false;
254
255 setup_locale();
256 setup_tmpctx();
257
258 opt_register_noarg("--no-single-sources", opt_set_bool, &no_singles,
259 "Eliminate single-channel nodes");
260 opt_register_noarg("-h|--help", opt_usage_and_exit,
261 "<gossipstore> <srcid>|all <dstid>\n"
262 "A topology test program.",
263 "Get usage information");
264 opt_parse(&argc, argv, opt_log_stderr_exit);
265 if (argc != 4)
266 opt_usage_exit_fail("Expect 3 arguments");
267
268 tstart = time_mono();
269 map = gossmap_load(NULL, argv[1], NULL);
270 if (!map)
271 err(1, "Loading gossip store %s", argv[1]);
272 tstop = time_mono();
273
274 printf("# Time to load: %"PRIu64" msec\n",
275 time_to_msec(timemono_between(tstop, tstart)));
276
277 clean_topo(map, no_singles);
278 printf("# Reduced to %zu nodes and %zu channels\n",
279 gossmap_num_nodes(map), gossmap_num_chans(map));
280
281 if (!node_id_from_hexstr(argv[3], strlen(argv[3]), &dstid))
282 errx(1, "Bad dstid");
283 dst = gossmap_find_node(map, &dstid);
284 if (!dst)
285 errx(1, "Unknown destination node '%s'", argv[3]);
286
287 if (streq(argv[2], "all")) {
288 for (n = gossmap_first_node(map);
289 n;
290 n = gossmap_next_node(map, n)) {
291 measure_least_cost(map, n, dst);
292 clean_tmpctx();
293 }
294 } else {
295 struct node_id srcid;
296 if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &srcid))
297 errx(1, "Bad srcid");
298 n = gossmap_find_node(map, &srcid);
299 if (!n)
300 errx(1, "Unknown source node '%s'", argv[2]);
301 if (!measure_least_cost(map, n, dst))
302 exit(1);
303 }
304

Callers

nothing calls this directly

Calls 15

setup_localeFunction · 0.85
setup_tmpctxFunction · 0.85
opt_parseFunction · 0.85
opt_usage_exit_failFunction · 0.85
time_monoFunction · 0.85
gossmap_loadFunction · 0.85
errFunction · 0.85
time_to_msecFunction · 0.85
timemono_betweenFunction · 0.85
clean_topoFunction · 0.85
gossmap_num_nodesFunction · 0.85
gossmap_num_chansFunction · 0.85

Tested by

no test coverage detected