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