From c506d42679e29d47910f96a64a6fc63f394ccb55 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 4 Feb 2019 21:25:42 +1030 Subject: [PATCH] plugins: don't keep redundant jsonrpc pointer. We have ld already, just use that in the one place we need. Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 2 +- lightningd/plugin.c | 8 ++------ lightningd/plugin.h | 2 +- lightningd/test/run-find_my_abspath.c | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 78e4ee73e..de14eb374 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -215,7 +215,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) *code. Here we initialize the context that will keep track and control *the plugins. */ - ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc, ld); + ld->plugins = plugins_new(ld, ld->log_book, ld); return ld; } diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 14c5e5208..e3a1a9f5b 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -76,9 +76,6 @@ struct plugins { struct log *log; struct log_book *log_book; - /* RPC interface to bind JSON-RPC methods to */ - struct jsonrpc *rpc; - struct timers timers; struct lightningd *ld; }; @@ -93,14 +90,13 @@ struct plugin_opt { }; struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book, - struct jsonrpc *rpc, struct lightningd *ld) + struct lightningd *ld) { struct plugins *p; p = tal(ctx, struct plugins); list_head_init(&p->plugins); p->log_book = log_book; p->log = new_log(p, log_book, "plugin-manager"); - p->rpc = rpc; timers_init(&p->timers, time_mono()); p->ld = ld; return p; @@ -679,7 +675,7 @@ static bool plugin_rpcmethod_add(struct plugin *plugin, cmd->deprecated = false; cmd->dispatch = plugin_rpcmethod_dispatch; - if (!jsonrpc_command_add(plugin->plugins->rpc, cmd)) { + if (!jsonrpc_command_add(plugin->plugins->ld->jsonrpc, cmd)) { log_broken(plugin->log, "Could not register method \"%s\", a method with " "that name is already registered", diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 408a5c95a..c9407b366 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -22,7 +22,7 @@ struct plugin; * Create a new plugins context. */ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book, - struct jsonrpc *rpc, struct lightningd *ld); + struct lightningd *ld); /** * Initialize the registered plugins. diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 7310a8041..42dbe5372 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -137,7 +137,7 @@ void plugins_init(struct plugins *plugins UNNEEDED, const char *dev_plugin_debug { fprintf(stderr, "plugins_init called!\n"); abort(); } /* Generated stub for plugins_new */ struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED, - struct jsonrpc *rpc UNNEEDED, struct lightningd *ld UNNEEDED) + struct lightningd *ld UNNEEDED) { fprintf(stderr, "plugins_new called!\n"); abort(); } /* Generated stub for register_opts */ void register_opts(struct lightningd *ld UNNEEDED)