MCPcopy Create free account
hub / github.com/ElementsProject/lightning / connect_failed

Function connect_failed

lightningd/connect_control.c:284–320  ·  view source on GitHub ↗

We were trying to connect, but they disconnected. */

Source from the content-addressed store, hash-verified

282
283/* We were trying to connect, but they disconnected. */
284static void connect_failed(struct lightningd *ld,
285 const struct node_id *id,
286 const struct wireaddr_internal *addrhint,
287 const char *connect_reason,
288 u64 connect_nsec,
289 enum jsonrpc_errcode errcode,
290 const char *errmsg,
291 bool connect_attempted)
292{
293 struct connect *c;
294
295 /* Don't record twice. */
296 if (errcode != CONNECT_DISCONNECTED_DURING)
297 wallet_save_network_event(ld, id,
298 NETWORK_EVENT_CONNECTFAIL,
299 errmsg,
300 connect_nsec,
301 connect_attempted);
302
303 /* There's a race between autoreconnect and connect commands. This
304 * matters because the autoreconnect might have failed, but that was before
305 * the connect_to_peer command gave connectd a new address. This we wait for
306 * one we explicitly asked for before failing.
307 *
308 * A similar pattern could occur with multiple connect commands, however connectd
309 * does simply combine those, so we don't get a response per request, and it's a
310 * very rare corner case (which, unlike the above, doesn't happen in CI!).
311 */
312 if (strstarts(connect_reason, "connect command")
313 || errcode == CONNECT_DISCONNECTED_DURING) {
314 /* We can have multiple connect commands: fail them all */
315 while ((c = find_connect(ld, id)) != NULL) {
316 /* They delete themselves from list */
317 was_pending(command_fail(c->cmd, errcode, "%s", errmsg));
318 }
319 }
320}
321
322void connect_failed_disconnect(struct lightningd *ld,
323 const struct node_id *id,

Callers 2

handle_connect_failedFunction · 0.70

Calls 4

find_connectFunction · 0.85
was_pendingFunction · 0.70
command_failFunction · 0.70

Tested by

no test coverage detected