node: source connection start/activity timestamps from the peer machine

The connection leg's started_at and last_activity duplicated the peer
machine's own connection-state copy. Make the machine copy the sole live
telemetry and timeout carrier: re-stamp it with the leg's provenance when
the leg is attached at handshake start (the msg1-prep clock, not the earlier
dial-time constructor value) and mirror the completion touch, then delete the
leg's last_activity/touch accessors and source the connection-row projection,
show_connections, and the timeout readers from the machine. Byte-identical
for all normal paths.
This commit is contained in:
Johnathan Corgan
2026-07-18 15:11:43 +00:00
parent 56bbc81a40
commit b3f2018fce
8 changed files with 95 additions and 22 deletions
+7
View File
@@ -1030,6 +1030,13 @@ impl Node {
(peer_identity, conn.our_index())
};
// Mirror the leg's completion `touch` on the surviving carrier so the
// connection's last-activity advances at msg2 completion, matching the
// leg's clock.
if let Some(machine) = self.peer_machines.get_mut(&link_id) {
machine.touch_conn(packet.timestamp_ms);
}
if self
.authorize_peer(
&peer_identity,
+12 -4
View File
@@ -20,9 +20,9 @@ impl LifecycleView for Node {
self.peer_machines
.iter()
.filter_map(|(link_id, machine)| machine.leg().map(|conn| (link_id, machine, conn)))
.filter(|(link_id, machine, conn)| {
.filter(|(link_id, machine, _conn)| {
machine.is_failed()
|| (conn.is_timed_out(now_ms, timeout_ms)
|| (machine.conn_is_timed_out(now_ms, timeout_ms)
&& !self.peer_timers.get(*link_id).is_some_and(|timers| {
timers.contains_key(&TimerKind::HandshakeTimeout)
}))
@@ -89,7 +89,8 @@ impl Node {
debug!(
link_id = %link,
direction = %direction,
idle_secs = conn.idle_time(now_ms) / 1000,
idle_secs =
now_ms.saturating_sub(self.connection_last_activity(link)) / 1000,
"Stale handshake connection timed out"
);
}
@@ -182,8 +183,15 @@ impl Node {
.map(|(link, _)| *link)
.collect();
for link in timer_links {
// The idle-timeout threshold reads the survivor carrier's
// last-activity (the leg no longer projects it); the leg still
// supplies direction/identity for the retry decision below.
let timed_out = self
.peer_machines
.get(&link)
.is_some_and(|machine| machine.conn_is_timed_out(now_ms, timeout_ms));
let (reap, retry_peer) = match self.leg(&link) {
Some(conn) if conn.is_timed_out(now_ms, timeout_ms) => {
Some(conn) if timed_out => {
let retry_peer = if conn.is_outbound() {
conn.expected_identity().map(|id| *id.node_addr())
} else {