Make auto-connect peers retry indefinitely on initial connection failure

Previously, static peers configured with AutoConnect gave up after 6
attempts (1 initial + 5 retries). If the remote peer was offline at
startup, the node permanently abandoned the connection. The reconnect
path (after MMP link-dead) already retried indefinitely but only
activated after a peer had been previously connected.

Remove the reconnect parameter from schedule_retry() and always set
reconnect=true when creating retry entries, since only auto-connect
peers reach this code path. The 300s backoff cap prevents resource waste.
The max_retries=0 config still works as an explicit kill switch.
This commit is contained in:
Johnathan Corgan
2026-03-15 18:43:11 +00:00
parent 959134657f
commit 324535e76d
4 changed files with 22 additions and 22 deletions
+3 -5
View File
@@ -59,11 +59,10 @@ impl Node {
&mut self,
node_addr: NodeAddr,
now_ms: u64,
reconnect: bool,
) {
let retry_cfg = &self.config.node.retry;
let max_retries = retry_cfg.max_retries;
if max_retries == 0 && !reconnect {
if max_retries == 0 {
return;
}
@@ -112,12 +111,11 @@ impl Node {
if let Some(pc) = peer_config {
let mut state = RetryState::new(pc);
state.retry_count = 1;
state.reconnect = reconnect;
state.reconnect = true;
let delay = state.backoff_ms(base_interval_ms, max_backoff_ms);
state.retry_after_ms = now_ms + delay;
debug!(
peer = %self.peer_display_name(&node_addr),
reconnect = reconnect,
delay_secs = delay / 1000,
"First connection attempt failed, scheduling retry"
);
@@ -237,7 +235,7 @@ impl Node {
);
// Immediate failure counts as an attempt — schedule next retry
// (reconnect flag is preserved on existing retry_pending entry)
self.schedule_retry(node_addr, now_ms, false);
self.schedule_retry(node_addr, now_ms);
}
}
}