Skip to content

Commit

Permalink
gossipd: use default zlib compression, hack for zlib expansion.
Browse files Browse the repository at this point in the history
These both allow us to reproduce the test vectors in the next patch.  But
using Z_DEFAULT_COMPRESSION is a reasonable idea anyway.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Aug 10, 2019
1 parent f6cf4bf commit 4de47f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,13 @@ static u8 *zencode(const tal_t *ctx, const u8 *scids, size_t len)
int err;
unsigned long compressed_len = len;

#ifdef ZLIB_EVEN_IF_EXPANDS
/* Needed for test vectors */
compressed_len = 128 * 1024;
#endif
/* Prefer to fail if zlib makes it larger */
z = tal_arr(ctx, u8, len);
err = compress2(z, &compressed_len, scids, len, Z_BEST_COMPRESSION);
z = tal_arr(ctx, u8, compressed_len);
err = compress2(z, &compressed_len, scids, len, Z_DEFAULT_COMPRESSION);
if (err == Z_OK) {
status_trace("compressed %zu into %lu",
len, compressed_len);
Expand Down

0 comments on commit 4de47f6

Please sign in to comment.