Skip to content

Commit 17ccd50

Browse files
committed
lightningd: implement listnetworkevents.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent acbaae2 commit 17ccd50

File tree

7 files changed

+501
-2
lines changed

7 files changed

+501
-2
lines changed

common/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ common/scb_wiregen.c_args := -s
133133

134134
# Check that all h and c files are in the Makefile!
135135
check-common-files:
136-
@$(call VERBOSE, "MISSING-SRC common", [ "$(filter-out $(COMMON_SRC), $(wildcard common/*.c))" = "" ])
137-
@$(call VERBOSE, "MISSING-HEADERS common", [ "$(filter-out $(COMMON_HEADERS) $(COMMON_SRC:.c=.h), $(wildcard common/*.h))" = "" ])
136+
@$(call VERBOSE, "checking common source", [ "$(filter-out $(COMMON_SRC), $(wildcard common/*.c))" = "" ])
137+
@$(call VERBOSE, "checking common headers", [ "$(filter-out $(COMMON_HEADERS) $(COMMON_SRC:.c=.h), $(wildcard common/*.h))" = "" ])
138138

139139
check-source: check-common-files
140140

contrib/msggen/msggen/schema.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21790,6 +21790,158 @@
2179021790
}
2179121791
]
2179221792
},
21793+
"listnetworkevents.json": {
21794+
"$schema": "../rpc-schema-draft.json",
21795+
"type": "object",
21796+
"rpc": "listnetworkevents",
21797+
"title": "Command for querying network events",
21798+
"added": "v25.12",
21799+
"description": [
21800+
"The **listnetworkevents** RPC command retrieves the log of connections, disconnections and pings on the network. This can be analyzed to evaluate node reliability and latency."
21801+
],
21802+
"categories": [
21803+
"readonly"
21804+
],
21805+
"request": {
21806+
"required": [],
21807+
"additionalProperties": false,
21808+
"properties": {
21809+
"id": {
21810+
"type": "string",
21811+
"description": [
21812+
"A node id: if set, only network events for this peer are returned"
21813+
]
21814+
},
21815+
"index": {
21816+
"type": "string",
21817+
"enum": [
21818+
"created"
21819+
],
21820+
"description": [
21821+
"This controls the ordering of results."
21822+
],
21823+
"default": "`created`"
21824+
},
21825+
"start": {
21826+
"type": "u64",
21827+
"description": [
21828+
"If `index` is specified, `start` may be specified to start from that value, which is generally returned from lightning-wait(7)."
21829+
]
21830+
},
21831+
"limit": {
21832+
"type": "u32",
21833+
"description": [
21834+
"If `index` is specified, `limit` can be used to specify the maximum number of entries to return."
21835+
]
21836+
}
21837+
}
21838+
},
21839+
"response": {
21840+
"required": [
21841+
"networkevents"
21842+
],
21843+
"additionalProperties": false,
21844+
"properties": {
21845+
"networkevents": {
21846+
"type": "array",
21847+
"items": {
21848+
"type": "object",
21849+
"additionalProperties": false,
21850+
"required": [
21851+
"created_index",
21852+
"timestamp",
21853+
"peer_id",
21854+
"type"
21855+
],
21856+
"properties": {
21857+
"created_index": {
21858+
"type": "u64",
21859+
"description": [
21860+
"1-based index indicating order this network event was created in."
21861+
]
21862+
},
21863+
"timestamp": {
21864+
"type": "u64",
21865+
"description": [
21866+
"Time this event was recorded, in seconds since January 1 1970 UTC"
21867+
]
21868+
},
21869+
"peer_id": {
21870+
"type": "pubkey",
21871+
"description": [
21872+
"The node the network connection was talking to."
21873+
]
21874+
},
21875+
"type": {
21876+
"type": "string",
21877+
"description": [
21878+
"The type of event (currently `ping`, `connect`, `connect_fail` or `disconnect`)"
21879+
]
21880+
},
21881+
"reason": {
21882+
"type": "string",
21883+
"description": [
21884+
"The cause of the event (if known)"
21885+
]
21886+
},
21887+
"duration_nsec": {
21888+
"type": "u64",
21889+
"description": [
21890+
"The time taken (for ping, the latency, for connect / connect_fail, the time taken to get a result, for disconnect, the time we were connected)"
21891+
]
21892+
},
21893+
"connect_attempted": {}
21894+
},
21895+
"allOf": [
21896+
{
21897+
"if": {
21898+
"additionalProperties": true,
21899+
"properties": {
21900+
"type": {
21901+
"type": "string",
21902+
"enum": [
21903+
"connect_fail"
21904+
]
21905+
}
21906+
}
21907+
},
21908+
"then": {
21909+
"additionalProperties": false,
21910+
"required": [
21911+
"connect_attempted"
21912+
],
21913+
"properties": {
21914+
"connect_attempted": {
21915+
"type": "boolean",
21916+
"description": [
21917+
"True if we found an address we could attempt to connect to, e.g. ignoring Tor addresses if we don't have a proxy, and ignoring IPv6 addresses if we don't have IPv6 support."
21918+
]
21919+
},
21920+
"created_index": {},
21921+
"timestamp": {},
21922+
"peer_id": {},
21923+
"type": {},
21924+
"reason": {},
21925+
"duration_nsec": {}
21926+
}
21927+
}
21928+
}
21929+
]
21930+
}
21931+
}
21932+
}
21933+
},
21934+
"author": [
21935+
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
21936+
],
21937+
"see_also": [
21938+
"lightning-autoclean(7)",
21939+
"lightning-listpeers(7)"
21940+
],
21941+
"resources": [
21942+
"Main web site: <https://github.com/ElementsProject/lightning>"
21943+
]
21944+
},
2179321945
"listnodes.json": {
2179421946
"$schema": "../rpc-schema-draft.json",
2179521947
"type": "object",

doc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ MARKDOWNPAGES := doc/addgossip.7 \
8989
doc/listhtlcs.7 \
9090
doc/listinvoicerequests.7 \
9191
doc/listinvoices.7 \
92+
doc/listnetworkevents.7 \
9293
doc/listnodes.7 \
9394
doc/listoffers.7 \
9495
doc/listpays.7 \

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Core Lightning Documentation
103103
listhtlcs <listhtlcs.7.md>
104104
listinvoicerequests <listinvoicerequests.7.md>
105105
listinvoices <listinvoices.7.md>
106+
listnetworkevents <listnetworkevents.7.md>
106107
listnodes <listnodes.7.md>
107108
listoffers <listoffers.7.md>
108109
listpays <listpays.7.md>

doc/schemas/listnetworkevents.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"$schema": "../rpc-schema-draft.json",
3+
"type": "object",
4+
"rpc": "listnetworkevents",
5+
"title": "Command for querying network events",
6+
"added": "v25.12",
7+
"description": [
8+
"The **listnetworkevents** RPC command retrieves the log of connections, disconnections and pings on the network. This can be analyzed to evaluate node reliability and latency."
9+
],
10+
"categories": [
11+
"readonly"
12+
],
13+
"request": {
14+
"required": [],
15+
"additionalProperties": false,
16+
"properties": {
17+
"id": {
18+
"type": "string",
19+
"description": [
20+
"A node id: if set, only network events for this peer are returned"
21+
]
22+
},
23+
"index": {
24+
"type": "string",
25+
"enum": [
26+
"created"
27+
],
28+
"description": [
29+
"This controls the ordering of results."
30+
],
31+
"default": "`created`"
32+
},
33+
"start": {
34+
"type": "u64",
35+
"description": [
36+
"If `index` is specified, `start` may be specified to start from that value, which is generally returned from lightning-wait(7)."
37+
]
38+
},
39+
"limit": {
40+
"type": "u32",
41+
"description": [
42+
"If `index` is specified, `limit` can be used to specify the maximum number of entries to return."
43+
]
44+
}
45+
}
46+
},
47+
"response": {
48+
"required": [
49+
"networkevents"
50+
],
51+
"additionalProperties": false,
52+
"properties": {
53+
"networkevents": {
54+
"type": "array",
55+
"items": {
56+
"type": "object",
57+
"additionalProperties": false,
58+
"required": [
59+
"created_index",
60+
"timestamp",
61+
"peer_id",
62+
"type"
63+
],
64+
"properties": {
65+
"created_index": {
66+
"type": "u64",
67+
"description": [
68+
"1-based index indicating order this network event was created in."
69+
]
70+
},
71+
"timestamp": {
72+
"type": "u64",
73+
"description": [
74+
"Time this event was recorded, in seconds since January 1 1970 UTC"
75+
]
76+
},
77+
"peer_id": {
78+
"type": "pubkey",
79+
"description": [
80+
"The node the network connection was talking to."
81+
]
82+
},
83+
"type": {
84+
"type": "string",
85+
"description": [
86+
"The type of event (currently `ping`, `connect`, `connect_fail` or `disconnect`)"
87+
]
88+
},
89+
"reason": {
90+
"type": "string",
91+
"description": [
92+
"The cause of the event (if known)"
93+
]
94+
},
95+
"duration_nsec": {
96+
"type": "u64",
97+
"description": [
98+
"The time taken (for ping, the latency, for connect / connect_fail, the time taken to get a result, for disconnect, the time we were connected)"
99+
]
100+
},
101+
"connect_attempted": {}
102+
},
103+
"allOf": [
104+
{
105+
"if": {
106+
"additionalProperties": true,
107+
"properties": {
108+
"type": {
109+
"type": "string",
110+
"enum": [
111+
"connect_fail"
112+
]
113+
}
114+
}
115+
},
116+
"then": {
117+
"additionalProperties": false,
118+
"required": [
119+
"connect_attempted"
120+
],
121+
"properties": {
122+
"connect_attempted": {
123+
"type": "boolean",
124+
"description": [
125+
"True if we found an address we could attempt to connect to, e.g. ignoring Tor addresses if we don't have a proxy, and ignoring IPv6 addresses if we don't have IPv6 support."
126+
]
127+
},
128+
"created_index": {},
129+
"timestamp": {},
130+
"peer_id": {},
131+
"type": {},
132+
"reason": {},
133+
"duration_nsec": {}
134+
}
135+
}
136+
}
137+
]
138+
}
139+
}
140+
}
141+
},
142+
"author": [
143+
"Rusty Russell <<rusty@rustcorp.com.au>> is mainly responsible."
144+
],
145+
"see_also": [
146+
"lightning-autoclean(7)",
147+
"lightning-listpeers(7)"
148+
],
149+
"resources": [
150+
"Main web site: <https://github.com/ElementsProject/lightning>"
151+
]
152+
}

0 commit comments

Comments
 (0)