tools/generate_wire.py: generate varlen arrays properly.

These are now logically arrays of pointers.  This is much more natural,
and gets rid of the horrible utxo array converters.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-02-08 11:54:46 +10:30
committed by Christian Decker
parent ad8dfaca1c
commit 526d3a232e
14 changed files with 105 additions and 121 deletions

View File

@@ -39,24 +39,3 @@ struct utxo *fromwire_utxo(const tal_t *ctx, const u8 **ptr, size_t *max)
}
return utxo;
}
struct utxo *from_utxoptr_arr(const tal_t *ctx, const struct utxo **utxos)
{
size_t i, n = tal_count(utxos);
struct utxo *utxo = tal_arr(ctx, struct utxo, n);
for (i = 0; i < n; i++)
utxo[i] = *utxos[i];
return utxo;
}
const struct utxo **to_utxoptr_arr(const tal_t *ctx, const struct utxo *utxos)
{
size_t i, n = tal_count(utxos);
const struct utxo **utxo = tal_arr(ctx, const struct utxo *, n);
for (i = 0; i < n; i++)
utxo[i] = &utxos[i];
return utxo;
}

View File

@@ -30,9 +30,4 @@ struct utxo {
void towire_utxo(u8 **pptr, const struct utxo *utxo);
struct utxo *fromwire_utxo(const tal_t *ctx, const u8 **ptr, size_t *max);
/* build_utxos/funding_tx use array of pointers, but marshall code
* wants arr of structs */
struct utxo *from_utxoptr_arr(const tal_t *ctx, const struct utxo **utxos);
const struct utxo **to_utxoptr_arr(const tal_t *ctx, const struct utxo *utxos);
#endif /* LIGHTNING_COMMON_UTXO_H */