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

Function main

devtools/create-gossipstore.c:96–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96int main(int argc, char *argv[])
97{
98 u8 version;
99 beint16_t be_inlen;
100 struct amount_sat sat;
101 bool verbose = false;
102 char *infile = NULL, *outfile = NULL, *csvfile = NULL, *csat = NULL;
103 int infd, outfd, scidi = 0, channels = 0, nodes = 0, updates = 0;
104 struct scidsat *scidsats = NULL;
105 const u8 *last_announce = NULL;
106 unsigned max = -1U;
107
108 setup_locale();
109
110 opt_register_noarg("--verbose|-v", opt_set_bool, &verbose,
111 "Print progress to stderr");
112 opt_register_arg("--output|-o", opt_set_charp, NULL, &outfile,
113 "Send output to this file instead of stdout");
114 opt_register_arg("--input|-i", opt_set_charp, NULL, &infile,
115 "Read input from this file instead of stdin");
116 opt_register_arg("--csv", opt_set_charp, NULL, &csvfile,
117 "Input for 'scid, satshis' csv");
118 opt_register_arg("--sat", opt_set_charp, NULL, &csat,
119 "default satoshi value if --csv flag not present");
120 opt_register_arg("--max", opt_set_uintval, opt_show_uintval, &max,
121 "maximum number of messages to read");
122 opt_register_noarg("--help|-h", opt_usage_and_exit,
123 "Create gossip store, from be16 / input messages",
124 "Print this message.");
125
126 opt_parse(&argc, argv, opt_log_stderr_exit);
127
128
129 if (csvfile && !csat) {
130 FILE *scidf;
131 scidf = fopen(csvfile, "r");
132 if (!scidf)
133 err(1, "opening %s", csvfile);
134 scidsats = load_csv_file(scidf);
135 fclose(scidf);
136 } else if (csat && !csvfile) {
137 if (!parse_amount_sat(&sat, csat, strlen(csat))) {
138 errx(1, "Invalid satoshi amount %s", csat);
139 }
140 }
141 else {
142 err(1, "must contain either --sat xor --csv");
143 }
144
145 if (infile) {
146 infd = open(infile, O_RDONLY);
147 if (infd < 0)
148 err(1, "opening %s", infile);
149 }
150 else
151 infd = STDIN_FILENO;
152
153 if (outfile) {

Callers

nothing calls this directly

Calls 15

setup_localeFunction · 0.85
opt_parseFunction · 0.85
errFunction · 0.85
load_csv_fileFunction · 0.85
errxFunction · 0.85
read_allFunction · 0.85
be16_to_cpuFunction · 0.85
fromwire_peektypeFunction · 0.85
short_channel_id_eqFunction · 0.85
get_update_timestampFunction · 0.85
write_outmsgFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected