tools/generate-wire: no more lonely messages!

When we have only a single member in a TLV (e.g. an optional u64),
wrapping it in a struct is awkward.  This changes it to directly
access those fields.

This is not only more elegant (60 fewer lines), it would also be
more cache friendly.  That's right: cache hot singles!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-05-06 20:11:54 +09:30
committed by neil saitug
parent 8d4abc1104
commit b0c9059602
14 changed files with 149 additions and 175 deletions

View File

@@ -156,9 +156,8 @@ static struct io_plan *handshake_success(struct io_conn *conn,
struct tlv_init_tlvs *tlvs = NULL;
if (chainparams) {
tlvs = tlv_init_tlvs_new(NULL);
tlvs->networks = tal(tlvs, struct tlv_init_tlvs_networks);
tlvs->networks->chains = tal_arr(tlvs->networks, struct bitcoin_blkid, 1);
tlvs->networks->chains[0] = chainparams->genesis_blockhash;
tlvs->networks = tal_arr(tlvs, struct bitcoin_blkid, 1);
tlvs->networks[0] = chainparams->genesis_blockhash;
}
msg = towire_init(NULL, NULL, features, tlvs);