core-lightning/lightningd/notification.c
Rusty Russell a2fa699e0e Use node_id everywhere for nodes.
I tried to just do gossipd, but it was uncontainable, so this ended up being
a complete sweep.

We didn't get much space saving in gossipd, even though we should save
24 bytes per node.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00

36 lines
994 B
C

#include "lightningd/notification.h"
#include <ccan/array_size/array_size.h>
const char *notification_topics[] = {
"connect",
"disconnect",
};
bool notifications_have_topic(const char *topic)
{
for (size_t i=0; i<ARRAY_SIZE(notification_topics); i++)
if (streq(topic, notification_topics[i]))
return true;
return false;
}
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]);
json_add_node_id(n->stream, "id", nodeid);
json_add_address_internal(n->stream, "address", addr);
jsonrpc_notification_end(n);
plugins_notify(ld->plugins, take(n));
}
void notify_disconnect(struct lightningd *ld, struct node_id *nodeid)
{
struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, notification_topics[1]);
json_add_node_id(n->stream, "id", nodeid);
jsonrpc_notification_end(n);
plugins_notify(ld->plugins, take(n));
}