All templates are of the same form. Output all the distinct values, then * write out which one is used by each channel */
| 173 | /* All templates are of the same form. Output all the distinct values, then |
| 174 | * write out which one is used by each channel */ |
| 175 | static 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 | |
| 197 | static void write_bidir_perchan(gzFile outf, |
| 198 | struct gossmap *gossmap, |
no test coverage detected