gossmap-compress: sort nodes into most to least as intended.

Interestingly, compressed sizes don't change, but uncompressed does:

```
$ file /tmp/gs.out-wrongorder
/tmp/gs.out-wrongorder: gzip compressed data, max compression, from Unix, original size modulo 2^32 1594822
$ ls -l /tmp/gs.out-wrongorder 
-rw-rw-r-- 1 rusty rusty 494337 Sep 20 13:34 /tmp/gs.out-wrongorder
$ file /tmp/gs.out
/tmp/gs.out: gzip compressed data, max compression, from Unix, original size modulo 2^32 1498634
$ ls -l /tmp/gs.out
-rw-rw-r-- 1 rusty rusty 494353 Sep 20 13:33 /tmp/gs.out
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-10-02 16:22:26 +09:30
parent 7ac32ebbf8
commit d143c22976

View File

@@ -84,11 +84,12 @@ static unsigned int verbose = 0;
#define GC_HEADERLEN (sizeof(GC_HEADER))
#define GOSSIP_STORE_VER ((0 << 5) | 14)
/* Backwards, we want larger first */
static int cmp_node_num_chans(struct gossmap_node *const *a,
struct gossmap_node *const *b,
void *unused)
{
return (int)(*a)->num_chans - (int)(*b)->num_chans;
return (int)(*b)->num_chans - (int)(*a)->num_chans;
}
static void write_bigsize(gzFile outf, u64 val)