Browse Source

lightningd/notification: use notification name in 'jsonrpc_notification_start()'

That way 'notification_topics' array modification would not lead to unwanted renaming
pull/2938/head
darosior 5 years ago
committed by Christian Decker
parent
commit
f55d29ee49
  1. 10
      lightningd/notification.c

10
lightningd/notification.c

@ -21,7 +21,7 @@ void notify_connect(struct lightningd *ld, struct node_id *nodeid,
struct wireaddr_internal *addr)
{
struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, notification_topics[0]);
jsonrpc_notification_start(NULL, "connect");
json_add_node_id(n->stream, "id", nodeid);
json_add_address_internal(n->stream, "address", addr);
jsonrpc_notification_end(n);
@ -31,7 +31,7 @@ void notify_connect(struct lightningd *ld, struct node_id *nodeid,
void notify_disconnect(struct lightningd *ld, struct node_id *nodeid)
{
struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, notification_topics[1]);
jsonrpc_notification_start(NULL, "disconnect");
json_add_node_id(n->stream, "id", nodeid);
jsonrpc_notification_end(n);
plugins_notify(ld->plugins, take(n));
@ -42,7 +42,7 @@ void notify_disconnect(struct lightningd *ld, struct node_id *nodeid)
void notify_warning(struct lightningd *ld, struct log_entry *l)
{
struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, notification_topics[2]);
jsonrpc_notification_start(NULL, "warning");
json_object_start(n->stream, "warning");
/* Choose "BROKEN"/"UNUSUAL" to keep consistent with the habit
* of plugin. But this may confuses the users who want to 'getlog'
@ -66,8 +66,8 @@ void notify_invoice_payment(struct lightningd *ld, struct amount_msat amount,
struct preimage preimage, const struct json_escape *label)
{
struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, notification_topics[3]);
json_object_start(n->stream, notification_topics[3]);
jsonrpc_notification_start(NULL, "invoice_payment");
json_object_start(n->stream, "invoice_payment");
json_add_string(n->stream, "msat",
type_to_string(tmpctx, struct amount_msat, &amount));
json_add_hex(n->stream, "preimage", &preimage, sizeof(preimage));

Loading…
Cancel
Save