diff --git a/lightningd/jsonrpc.c b/lightningd/jsonrpc.c index 8081393cb..72df06d88 100644 --- a/lightningd/jsonrpc.c +++ b/lightningd/jsonrpc.c @@ -803,20 +803,19 @@ bool jsonrpc_command_add(struct jsonrpc *rpc, struct json_command *command) return true; } -struct jsonrpc *jsonrpc_new(const tal_t *ctx, struct lightningd *ld) +void jsonrpc_setup(struct lightningd *ld) { - struct jsonrpc *jsonrpc = tal(ctx, struct jsonrpc); struct json_command **commands = get_cmdlist(); - jsonrpc->commands = tal_arr(jsonrpc, struct json_command *, 0); - jsonrpc->log = new_log(jsonrpc, ld->log_book, "jsonrpc"); + ld->jsonrpc = tal(ld, struct jsonrpc); + ld->jsonrpc->commands = tal_arr(ld->jsonrpc, struct json_command *, 0); + ld->jsonrpc->log = new_log(ld->jsonrpc, ld->log_book, "jsonrpc"); for (size_t i=0; ijsonrpc, commands[i])) fatal("Cannot add duplicate command %s", commands[i]->name); } - jsonrpc->rpc_listener = NULL; - return jsonrpc; + ld->jsonrpc->rpc_listener = NULL; } bool command_usage_only(const struct command *cmd) diff --git a/lightningd/jsonrpc.h b/lightningd/jsonrpc.h index f296fe75c..28141baac 100644 --- a/lightningd/jsonrpc.h +++ b/lightningd/jsonrpc.h @@ -8,6 +8,8 @@ #include #include +struct jsonrpc; + /* The command mode tells param() how to process. */ enum command_mode { /* Normal command processing */ @@ -152,8 +154,10 @@ struct command_result *command_its_complicated(const char *why); * This doesn't setup the listener yet, see `jsonrpc_listen` for * that. This just creates the container for all jsonrpc-related * information so we can start gathering it before actually starting. + * + * It initializes ld->jsonrpc. */ -struct jsonrpc *jsonrpc_new(const tal_t *ctx, struct lightningd *ld); +void jsonrpc_setup(struct lightningd *ld); /** diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 37f38aff1..78e4ee73e 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -207,7 +207,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) * lightningd needs to have something to put those in. This * is that :-) */ - ld->jsonrpc = jsonrpc_new(ld, ld); + jsonrpc_setup(ld); /*~ We run a number of plugins (subprocesses that we talk JSON-RPC with) *alongside this process. This allows us to have an easy way for users diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 47c5e7ed4..7310a8041 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -94,9 +94,9 @@ void htlcs_notify_new_block(struct lightningd *ld UNNEEDED, u32 height UNNEEDED) /* Generated stub for jsonrpc_listen */ void jsonrpc_listen(struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED) { fprintf(stderr, "jsonrpc_listen called!\n"); abort(); } -/* Generated stub for jsonrpc_new */ -struct jsonrpc *jsonrpc_new(const tal_t *ctx UNNEEDED, struct lightningd *ld UNNEEDED) -{ fprintf(stderr, "jsonrpc_new called!\n"); abort(); } +/* Generated stub for jsonrpc_setup */ +void jsonrpc_setup(struct lightningd *ld UNNEEDED) +{ fprintf(stderr, "jsonrpc_setup called!\n"); abort(); } /* Generated stub for load_channels_from_wallet */ void load_channels_from_wallet(struct lightningd *ld UNNEEDED) { fprintf(stderr, "load_channels_from_wallet called!\n"); abort(); }