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

Function write_template_and_values

devtools/gossmap-compress.c:175–195  ·  view source on GitHub ↗

All templates are of the same form. Output all the distinct values, then * write out which one is used by each channel */

Source from the content-addressed store, hash-verified

173/* All templates are of the same form. Output all the distinct values, then
174 * write out which one is used by each channel */
175static void write_template_and_values(gzFile outf, const u64 *vals, const char *what)
176{
177 /* Sort and remove dups */
178 const u64 *template = deduplicate(tmpctx, vals);
179
180 if (verbose)
181 printf("%zu unique %s\n", tal_count(template), what);
182
183 assert(tal_count(vals) >= tal_count(template));
184
185 /* Write template. */
186 write_bigsize(outf, tal_count(template));
187 for (size_t i = 0; i < tal_count(template); i++)
188 write_bigsize(outf, template[i]);
189
190 /* Tie every channel into the template. O(N^2) but who
191 * cares? */
192 for (size_t i = 0; i < tal_count(vals); i++) {
193 write_bigsize(outf, find_index(template, vals[i]));
194 }
195}
196
197static void write_bidir_perchan(gzFile outf,
198 struct gossmap *gossmap,

Callers 2

write_bidir_perchanFunction · 0.85
mainFunction · 0.85

Calls 3

deduplicateFunction · 0.85
write_bigsizeFunction · 0.85
find_indexFunction · 0.85

Tested by

no test coverage detected