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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-02-04 21:25:42 +10:30
parent dabdefefae
commit c506d42679
4 changed files with 5 additions and 9 deletions

View File

@ -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;
}

View File

@ -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",

View File

@ -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.

View File

@ -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)