Skip to content

Commit

Permalink
single plugin_notification_serialize function
Browse files Browse the repository at this point in the history
  • Loading branch information
gudnuf authored and cdecker committed Dec 6, 2024
1 parent e6313c1 commit 5e9ec0e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions lightningd/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ void notify_log(struct lightningd *ld, const struct log_entry *l)
notify_send(ld, n);
}

static void plugin_started_notification_serialize(struct json_stream *stream,
struct plugin *plugin)
static void plugin_notification_serialize(struct json_stream *stream,
struct plugin *plugin)
{
json_add_string(stream, "plugin_name", plugin->shortname);
json_add_string(stream, "plugin_path", plugin->cmd);
Expand All @@ -656,27 +656,15 @@ REGISTER_NOTIFICATION(plugin_started);
void notify_plugin_started(struct lightningd *ld, struct plugin *plugin)
{
struct jsonrpc_notification *n = notify_start("plugin_started");
plugin_started_notification_serialize(n->stream, plugin);
plugin_notification_serialize(n->stream, plugin);
notify_send(ld, n);
}

static void plugin_stopped_notification_serialize(struct json_stream *stream,
struct plugin *plugin)
{
json_add_string(stream, "plugin_name", plugin->shortname);
json_add_string(stream, "plugin_path", plugin->cmd);
json_array_start(stream, "methods");
for (size_t i = 0; i < tal_count(plugin->methods); i++) {
json_add_string(stream, NULL, plugin->methods[i]);
}
json_array_end(stream);
}

REGISTER_NOTIFICATION(plugin_stopped);

void notify_plugin_stopped(struct lightningd *ld, struct plugin *plugin)
{
struct jsonrpc_notification *n = notify_start("plugin_stopped");
plugin_stopped_notification_serialize(n->stream, plugin);
plugin_notification_serialize(n->stream, plugin);
notify_send(ld, n);
}

0 comments on commit 5e9ec0e

Please sign in to comment.