Browse Source

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>
fix-test_pay_direct-flake
Rusty Russell 6 years ago
parent
commit
c506d42679
  1. 2
      lightningd/lightningd.c
  2. 8
      lightningd/plugin.c
  3. 2
      lightningd/plugin.h
  4. 2
      lightningd/test/run-find_my_abspath.c

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

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

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

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

Loading…
Cancel
Save