mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
plugin: Register connect
notification
This commit is contained in:
parent
25d79c5c3f
commit
c289fa8f19
@ -5,7 +5,6 @@
|
||||
#include <lightningd/peer_htlcs.h>
|
||||
|
||||
const char *notification_topics[] = {
|
||||
"connect",
|
||||
"disconnect",
|
||||
"warning",
|
||||
"invoice_payment",
|
||||
@ -39,13 +38,27 @@ bool notifications_have_topic(const char *topic)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void connect_notification_serialize(struct json_stream *stream,
|
||||
struct node_id *nodeid,
|
||||
struct wireaddr_internal *addr)
|
||||
{
|
||||
json_add_node_id(stream, "id", nodeid);
|
||||
json_add_address_internal(stream, "address", addr);
|
||||
}
|
||||
|
||||
REGISTER_NOTIFICATION(connect,
|
||||
connect_notification_serialize);
|
||||
|
||||
void notify_connect(struct lightningd *ld, struct node_id *nodeid,
|
||||
struct wireaddr_internal *addr)
|
||||
{
|
||||
struct jsonrpc_notification *n =
|
||||
jsonrpc_notification_start(NULL, "connect");
|
||||
json_add_node_id(n->stream, "id", nodeid);
|
||||
json_add_address_internal(n->stream, "address", addr);
|
||||
void (*serialize)(struct json_stream *,
|
||||
struct node_id *,
|
||||
struct wireaddr_internal *) = connect_notification_gen.serialize;
|
||||
|
||||
struct jsonrpc_notification *n
|
||||
= jsonrpc_notification_start(NULL, connect_notification_gen.topic);
|
||||
serialize(n->stream, nodeid, addr);
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
@ -149,7 +162,3 @@ void notify_forward_event(struct lightningd *ld,
|
||||
jsonrpc_notification_end(n);
|
||||
plugins_notify(ld->plugins, take(n));
|
||||
}
|
||||
|
||||
/* TODO: It's a dummy notification. Will be removed when we have a 'real' one
|
||||
* in this file. */
|
||||
REGISTER_JSON_INTERNAL_COMMAND(hello_notification, NULL, void *);
|
||||
|
Loading…
Reference in New Issue
Block a user