plugins/libplugin: flatten return from json_to_listpeers_result.

Instead of returning a peers -> channels heirarchy, return (as callers
want!) a flat array of channels.

This is actually most of the transition work to make them work with
listpeerchannels.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-01-12 11:48:10 +10:30
parent cb5ee7e49c
commit 57dcf68c0b
4 changed files with 51 additions and 99 deletions

View File

@@ -433,6 +433,8 @@ void NORETURN LAST_ARG_NULL plugin_main(char *argv[],
...);
struct listpeers_channel {
struct node_id id;
bool connected;
bool private;
struct bitcoin_txid funding_txid;
const char *state;
@@ -444,21 +446,10 @@ struct listpeers_channel {
/* TODO Add fields as we need them. */
};
struct listpeers_peer {
struct node_id id;
bool connected;
const char **netaddr;
struct feature_set *features;
struct listpeers_channel **channels;
};
struct listpeers_result {
struct listpeers_peer **peers;
};
struct listpeers_result *json_to_listpeers_result(const tal_t *ctx,
const char *buffer,
const jsmntok_t *tok);
/* Returns an array of listpeers_channel * */
struct listpeers_channel **json_to_listpeers_channels(const tal_t *ctx,
const char *buffer,
const jsmntok_t *tok);
struct createonion_response {
u8 *onion;