|
@ -347,11 +347,12 @@ static const struct json_command *find_cmd(const struct jsonrpc *rpc, |
|
|
{ |
|
|
{ |
|
|
struct json_command **commands = rpc->commands; |
|
|
struct json_command **commands = rpc->commands; |
|
|
|
|
|
|
|
|
/* commands[i]->name can be NULL in test code. */ |
|
|
/* commands[i] can be NULL if the plugin that registered it
|
|
|
for (size_t i=0; i<tal_count(commands); i++) |
|
|
* was killed, commands[i]->name can be NULL in test code. */ |
|
|
if (commands[i]->name && |
|
|
for (size_t i = 0; i < tal_count(commands); i++) |
|
|
json_tok_streq(buffer, tok, commands[i]->name)) |
|
|
if (commands[i] && commands[i]->name && |
|
|
return commands[i]; |
|
|
json_tok_streq(buffer, tok, commands[i]->name)) |
|
|
|
|
|
return commands[i]; |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -738,6 +739,18 @@ bool jsonrpc_command_add(struct jsonrpc *rpc, struct json_command *command) |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void jsonrpc_command_remove(struct jsonrpc *rpc, const char *method) |
|
|
|
|
|
{ |
|
|
|
|
|
// FIXME: Currently leaves NULL entries in the table, if we
|
|
|
|
|
|
// restart plugins we should shift them out.
|
|
|
|
|
|
for (size_t i=0; i<tal_count(rpc->commands); i++) { |
|
|
|
|
|
struct json_command *cmd = rpc->commands[i]; |
|
|
|
|
|
if (cmd && streq(cmd->name, method)) { |
|
|
|
|
|
rpc->commands[i] = tal_free(cmd); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
struct jsonrpc *jsonrpc_new(const tal_t *ctx, struct lightningd *ld) |
|
|
struct jsonrpc *jsonrpc_new(const tal_t *ctx, struct lightningd *ld) |
|
|
{ |
|
|
{ |
|
|
struct jsonrpc *jsonrpc = tal(ctx, struct jsonrpc); |
|
|
struct jsonrpc *jsonrpc = tal(ctx, struct jsonrpc); |
|
|