mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
notification: connect with json key connect
This commit is contained in:
committed by
Rusty Russell
parent
d58414b062
commit
e247d16536
@@ -513,9 +513,11 @@ to a peer is established. `direction` is either `"in"` or `"out"`.
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432",
|
||||
"direction": "in",
|
||||
"address": "1.2.3.4:1234"
|
||||
"connect": {
|
||||
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432",
|
||||
"direction": "in",
|
||||
"address": "1.2.3.4:1234"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -87,9 +87,11 @@ A notification for topic `connect` is sent every time a new connection to a peer
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432",
|
||||
"direction": "in",
|
||||
"address": "1.2.3.4:1234"
|
||||
"connect": {
|
||||
"id": "02f6725f9c1c40333b67faea92fd211c183050f28df32cac3f9d69685fe9665432",
|
||||
"direction": "in",
|
||||
"address": "1.2.3.4:1234"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ bool notifications_have_topic(const struct plugins *plugins, const char *topic)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void connect_notification_serialize(struct json_stream *stream,
|
||||
static void json_add_connect_fields(struct json_stream *stream,
|
||||
const struct node_id *nodeid,
|
||||
bool incoming,
|
||||
const struct wireaddr_internal *addr)
|
||||
@@ -51,6 +51,19 @@ static void connect_notification_serialize(struct json_stream *stream,
|
||||
json_add_address_internal(stream, "address", addr);
|
||||
}
|
||||
|
||||
static void connect_notification_serialize(struct json_stream *stream,
|
||||
const struct node_id *nodeid,
|
||||
bool incoming,
|
||||
const struct wireaddr_internal *addr)
|
||||
{
|
||||
/* Old style: Add raw fields without connect key */
|
||||
/* FIXME: Deprecate! */
|
||||
json_add_connect_fields(stream, nodeid, incoming, addr);
|
||||
json_object_start(stream, "connect");
|
||||
json_add_connect_fields(stream, nodeid, incoming, addr);
|
||||
json_object_end(stream);
|
||||
}
|
||||
|
||||
REGISTER_NOTIFICATION(connect,
|
||||
connect_notification_serialize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user