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

Function main

devtools/convert-gossmap.c:62–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62int main(int argc, char *argv[])
63{
64 u8 oldversion, version;
65 struct gossip_hdr hdr;
66
67 setup_locale();
68 if (!read_all(STDIN_FILENO, &oldversion, sizeof(oldversion)))
69 errx(1, "Empty file");
70
71 if (GOSSIP_STORE_MAJOR_VERSION(oldversion) != GSTORE_MAJOR)
72 errx(1, "Unsupported major gossip_version %u (expected %u)",
73 GOSSIP_STORE_MAJOR_VERSION(oldversion), GSTORE_MAJOR);
74
75 version = ((GSTORE_MAJOR << 5) | GSTORE_MINOR);
76 if (!write_all(STDOUT_FILENO, &version, sizeof(version)))
77 err(1, "Write error");
78
79 while (read_all(STDIN_FILENO, &hdr, sizeof(hdr))) {
80 u8 *msg;
81 msg = tal_arr(NULL, u8, be16_to_cpu(hdr.len));
82 if (!read_all(STDIN_FILENO, msg, tal_bytelen(msg)))
83 err(1, "truncated file");
84 if (!upgrade_field(oldversion, &hdr.flags, &msg))
85 errx(1, "Cannot upgrade from version %u", oldversion);
86 if (msg) {
87 if (!write_all(STDOUT_FILENO, &hdr, sizeof(hdr))
88 || !write_all(STDOUT_FILENO, msg, tal_bytelen(msg)))
89 err(1, "Write error");
90 tal_free(msg);
91 }
92 }
93 return 0;
94}

Callers

nothing calls this directly

Calls 9

setup_localeFunction · 0.85
read_allFunction · 0.85
errxFunction · 0.85
errFunction · 0.85
be16_to_cpuFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
upgrade_fieldFunction · 0.70
write_allFunction · 0.50

Tested by

no test coverage detected