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

Function try_reconnect

lightningd/connect_control.c:332–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330#define MAX_WAIT_SECONDS 300
331
332void try_reconnect(const tal_t *ctx,
333 struct peer *peer,
334 const struct wireaddr_internal *addrhint)
335{
336 if (!peer->ld->reconnect)
337 return;
338
339 /* Did we last attempt to connect recently? Enter backoff mode. */
340 if (time_less(time_between(time_now(), peer->last_connect_attempt),
341 time_from_sec(MAX_WAIT_SECONDS * 2))) {
342 u32 max = DEV_FAST_RECONNECT(peer->ld->dev_fast_reconnect,
343 3, MAX_WAIT_SECONDS);
344 peer->reconnect_delay *= 2;
345 if (peer->reconnect_delay > max)
346 peer->reconnect_delay = max;
347 } else
348 peer->reconnect_delay = INITIAL_WAIT_SECONDS;
349
350 try_connect(ctx,
351 peer->ld,
352 &peer->id,
353 peer->reconnect_delay,
354 addrhint);
355}
356
357/* We were trying to connect, but they disconnected. */
358static void connect_failed(struct lightningd *ld,

Callers 4

wallet_commit_channelFunction · 0.70
setup_peerFunction · 0.70
wallet_commit_channelFunction · 0.70
connect_failedFunction · 0.70

Calls 5

time_lessFunction · 0.85
time_betweenFunction · 0.85
time_nowFunction · 0.85
time_from_secFunction · 0.85
try_connectFunction · 0.85

Tested by

no test coverage detected