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

Function main

devtools/route.c:64–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64int main(int argc, char *argv[])
65{
66 struct timemono tstart, tstop;
67 struct gossmap_node *n, *dst;
68 struct gossmap *map;
69 struct node_id dstid;
70 bool clean_topology = false;
71 size_t num_channel_updates_rejected;
72
73 opt_register_noarg("--clean-topology", opt_set_bool, &clean_topology,
74 "Clean up topology before run");
75 opt_register_noarg("-h|--help", opt_usage_and_exit,
76 "<gossipstore> <srcid>|all <dstid>\n"
77 "A routing test and benchmark program.",
78 "Get usage information");
79 opt_parse(&argc, argv, opt_log_stderr_exit);
80 if (argc != 4)
81 opt_usage_exit_fail("Expect 3 arguments");
82
83 tstart = time_mono();
84 map = gossmap_load(NULL, argv[1], &num_channel_updates_rejected);
85 if (!map)
86 err(1, "Loading gossip store %s", argv[1]);
87 tstop = time_mono();
88
89 printf("# Time to load: %"PRIu64" msec (%zu ignored)\n",
90 time_to_msec(timemono_between(tstop, tstart)),
91 num_channel_updates_rejected);
92
93 if (clean_topology)
94 clean_topo(map, false);
95
96 if (!node_id_from_hexstr(argv[3], strlen(argv[3]), &dstid))
97 errx(1, "Bad dstid");
98 dst = gossmap_find_node(map, &dstid);
99 if (!dst)
100 errx(1, "Unknown destination node '%s'", argv[3]);
101
102 if (streq(argv[2], "all")) {
103 for (n = gossmap_first_node(map);
104 n;
105 n = gossmap_next_node(map, n)) {
106 struct node_id srcid;
107
108 gossmap_node_get_id(map, n, &srcid);
109 printf("# %s->%s\n",
110 type_to_string(tmpctx, struct node_id, &srcid),
111 type_to_string(tmpctx, struct node_id, &dstid));
112 tal_free(least_cost(map, n, dst));
113 }
114 } else {
115 struct route_hop *path;
116 struct node_id srcid;
117
118 if (!node_id_from_hexstr(argv[2], strlen(argv[2]), &srcid))
119 errx(1, "Bad srcid");
120 n = gossmap_find_node(map, &srcid);
121 if (!n)

Callers

nothing calls this directly

Calls 15

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
errxFunction · 0.85
gossmap_find_nodeFunction · 0.85
gossmap_first_nodeFunction · 0.85
gossmap_next_nodeFunction · 0.85

Tested by

no test coverage detected