diff --git a/common/Makefile b/common/Makefile index e9dd1d4e7..28ddaab6d 100644 --- a/common/Makefile +++ b/common/Makefile @@ -15,7 +15,7 @@ COMMON_SRC_NOGEN := \ common/cryptomsg.c \ common/daemon.c \ common/daemon_conn.c \ - common/decode_short_channel_ids.c \ + common/decode_array.c \ common/derive_basepoints.c \ common/dev_disconnect.c \ common/features.c \ diff --git a/common/decode_short_channel_ids.c b/common/decode_array.c similarity index 93% rename from common/decode_short_channel_ids.c rename to common/decode_array.c index 80d349e51..a64904a70 100644 --- a/common/decode_short_channel_ids.c +++ b/common/decode_array.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded) { struct short_channel_id *scids; size_t max = tal_count(encoded); - enum scid_encode_types type; + enum arr_encode_types type; /* BOLT #7: * @@ -41,13 +41,13 @@ struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded) */ type = fromwire_u8(&encoded, &max); switch (type) { - case SHORTIDS_ZLIB: + case ARR_ZLIB: encoded = unzlib(tmpctx, encoded, max); if (!encoded) return NULL; max = tal_count(encoded); /* fall thru */ - case SHORTIDS_UNCOMPRESSED: + case ARR_UNCOMPRESSED: scids = tal_arr(ctx, struct short_channel_id, 0); while (max) { struct short_channel_id scid; @@ -82,13 +82,13 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx, * - MAY fail the connection. */ switch (qf->encoding_type) { - case SHORTIDS_ZLIB: + case ARR_ZLIB: encoded = unzlib(tmpctx, encoded, max); if (!encoded) return NULL; max = tal_count(encoded); /* fall thru */ - case SHORTIDS_UNCOMPRESSED: + case ARR_UNCOMPRESSED: flags = tal_arr(ctx, bigsize_t, 0); while (max) tal_arr_expand(&flags, diff --git a/common/decode_short_channel_ids.h b/common/decode_array.h similarity index 85% rename from common/decode_short_channel_ids.h rename to common/decode_array.h index 9be3f21d6..2e642e404 100644 --- a/common/decode_short_channel_ids.h +++ b/common/decode_array.h @@ -1,5 +1,5 @@ -#ifndef LIGHTNING_COMMON_DECODE_SHORT_CHANNEL_IDS_H -#define LIGHTNING_COMMON_DECODE_SHORT_CHANNEL_IDS_H +#ifndef LIGHTNING_COMMON_DECODE_ARRAY_H +#define LIGHTNING_COMMON_DECODE_ARRAY_H #include "config.h" #include #include @@ -13,9 +13,9 @@ struct tlv_query_short_channel_ids_tlvs_query_flags; * * `0`: uncompressed array of `short_channel_id` types, in ascending order. * * `1`: array of `short_channel_id` types, in ascending order, compressed with zlib deflate[1](#reference-1) */ -enum scid_encode_types { - SHORTIDS_UNCOMPRESSED = 0, - SHORTIDS_ZLIB = 1 +enum arr_encode_types { + ARR_UNCOMPRESSED = 0, + ARR_ZLIB = 1 }; struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded); @@ -44,4 +44,4 @@ enum scid_query_flag { bigsize_t *decode_scid_query_flags(const tal_t *ctx, const struct tlv_query_short_channel_ids_tlvs_query_flags *qf); -#endif /* LIGHTNING_COMMON_DECODE_SHORT_CHANNEL_IDS_H */ +#endif /* LIGHTNING_COMMON_DECODE_ARRAY_H */ diff --git a/connectd/connectd.c b/connectd/connectd.c index 5d125eecc..9e68e6478 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/devtools/Makefile b/devtools/Makefile index ec416fa3a..0fd8f625a 100644 --- a/devtools/Makefile +++ b/devtools/Makefile @@ -14,7 +14,7 @@ DEVTOOLS_COMMON_OBJS := \ common/bigsize.o \ common/bolt11.o \ common/crypto_state.o \ - common/decode_short_channel_ids.o \ + common/decode_array.o \ common/features.o \ common/gossip_rcvd_filter.o \ common/hash_u5.o \ diff --git a/devtools/decodemsg.c b/devtools/decodemsg.c index ada69aa7c..4938ebdb6 100644 --- a/devtools/decodemsg.c +++ b/devtools/decodemsg.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/devtools/mkencoded.c b/devtools/mkencoded.c index e0bcdab66..91d3a1eac 100644 --- a/devtools/mkencoded.c +++ b/devtools/mkencoded.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,9 +41,9 @@ int main(int argc, char *argv[]) if (!hex_decode(argv[1], strlen(argv[1]), &encoding, sizeof(encoding))) errx(1, "Expected single hex byte not %s", argv[1]); - if (encoding == SHORTIDS_UNCOMPRESSED) + if (encoding == ARR_UNCOMPRESSED) printf("%02x%s\n", encoding, tal_hex(NULL, data)); - else if (encoding == SHORTIDS_ZLIB) { + else if (encoding == ARR_ZLIB) { /* https://www.zlib.net/zlib_tech.html: * the only expansion is an overhead of five bytes per 16 KB * block (about 0.03%), plus a one-time overhead of six bytes diff --git a/devtools/print_wire.c b/devtools/print_wire.c index 675fe458f..64e395ca6 100644 --- a/devtools/print_wire.c +++ b/devtools/print_wire.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -114,10 +114,10 @@ static void printwire_encoded_short_ids(const u8 **cursor, size_t *plen, size_t scids = decode_short_ids(tmpctx, arr); if (scids) { switch (arr[0]) { - case SHORTIDS_UNCOMPRESSED: + case ARR_UNCOMPRESSED: printf(" (UNCOMPRESSED)"); break; - case SHORTIDS_ZLIB: + case ARR_ZLIB: printf(" (ZLIB)"); break; default: @@ -129,8 +129,8 @@ static void printwire_encoded_short_ids(const u8 **cursor, size_t *plen, size_t } else { /* If it was unknown, that's different from corrupt */ if (len == 0 - || arr[0] == SHORTIDS_UNCOMPRESSED - || arr[0] == SHORTIDS_ZLIB) { + || arr[0] == ARR_UNCOMPRESSED + || arr[0] == ARR_ZLIB) { printf(" **CORRUPT**"); return; } else { diff --git a/gossipd/Makefile b/gossipd/Makefile index 4eb781902..6875f1baa 100644 --- a/gossipd/Makefile +++ b/gossipd/Makefile @@ -49,7 +49,7 @@ GOSSIPD_COMMON_OBJS := \ common/cryptomsg.o \ common/daemon.o \ common/daemon_conn.o \ - common/decode_short_channel_ids.o \ + common/decode_array.o \ common/derive_basepoints.o \ common/dev_disconnect.o \ common/features.o \ diff --git a/gossipd/queries.c b/gossipd/queries.c index 66f46112c..b4d172d62 100644 --- a/gossipd/queries.c +++ b/gossipd/queries.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -116,10 +116,10 @@ static void encoding_end_no_compress(u8 **encoded, size_t off) static bool encoding_end_prepend_type(u8 **encoded, size_t max_bytes) { if (encoding_end_zlib(encoded, 1)) - **encoded = SHORTIDS_ZLIB; + **encoded = ARR_ZLIB; else { encoding_end_no_compress(encoded, 1); - **encoded = SHORTIDS_UNCOMPRESSED; + **encoded = ARR_UNCOMPRESSED; } #if DEVELOPER @@ -133,10 +133,10 @@ static bool encoding_end_prepend_type(u8 **encoded, size_t max_bytes) static UNNEEDED bool encoding_end_external_type(u8 **encoded, u8 *type, size_t max_bytes) { if (encoding_end_zlib(encoded, 0)) - *type = SHORTIDS_ZLIB; + *type = ARR_ZLIB; else { encoding_end_no_compress(encoded, 0); - *type = SHORTIDS_UNCOMPRESSED; + *type = ARR_UNCOMPRESSED; } return tal_count(*encoded) <= max_bytes; diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index 542da7a90..d5eef5e43 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -297,11 +297,11 @@ static u8 *get_scid_array(const tal_t *ctx, } if (json_tok_streq(test_vector, encoding, "UNCOMPRESSED")) { encoding_end_no_compress(&encoded, 1); - encoded[0] = SHORTIDS_UNCOMPRESSED; + encoded[0] = ARR_UNCOMPRESSED; } else { assert(json_tok_streq(test_vector, encoding, "COMPRESSED_ZLIB")); assert(encoding_end_zlib(&encoded, 1)); - encoded[0] = SHORTIDS_ZLIB; + encoded[0] = ARR_ZLIB; } return encoded; @@ -380,13 +380,13 @@ static u8 *test_reply_channel_range(const char *test_vector, const jsmntok_t *ob if (json_tok_streq(test_vector, encodingtok, "UNCOMPRESSED")) { encoding_end_no_compress(&tlvs->timestamps_tlv->encoded_timestamps, 0); - tlvs->timestamps_tlv->encoding_type = SHORTIDS_UNCOMPRESSED; + tlvs->timestamps_tlv->encoding_type = ARR_UNCOMPRESSED; } else { assert(json_tok_streq(test_vector, encodingtok, "COMPRESSED_ZLIB")); assert(encoding_end_zlib(&tlvs->timestamps_tlv->encoded_timestamps, 0)); - tlvs->timestamps_tlv->encoding_type = SHORTIDS_ZLIB; + tlvs->timestamps_tlv->encoding_type = ARR_ZLIB; } } @@ -443,11 +443,11 @@ get_query_flags_array(const tal_t *ctx, } if (json_tok_streq(test_vector, encoding, "UNCOMPRESSED")) { encoding_end_no_compress(&tlv->encoded_query_flags, 0); - tlv->encoding_type = SHORTIDS_UNCOMPRESSED; + tlv->encoding_type = ARR_UNCOMPRESSED; } else { assert(json_tok_streq(test_vector, encoding, "COMPRESSED_ZLIB")); assert(encoding_end_zlib(&tlv->encoded_query_flags, 0)); - tlv->encoding_type = SHORTIDS_ZLIB; + tlv->encoding_type = ARR_ZLIB; } return tlv;