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
+23 -2
View File
@@ -1982,8 +1982,8 @@ impl Node {
link_id: conn.link_id().as_u64(),
direction: format!("{}", conn.direction()),
handshake_state: self.connection_handshake_state(conn.link_id()).to_string(),
started_at_ms: conn.started_at(),
last_activity_ms: conn.last_activity(),
started_at_ms: self.connection_started_at(conn.link_id()),
last_activity_ms: self.connection_last_activity(conn.link_id()),
resend_count: self.connection_resend_count(conn.link_id()),
expected_peer: conn.expected_identity().map(|id| id.npub()),
})
@@ -2309,6 +2309,27 @@ impl Node {
.map_or(0, |machine| machine.resend_count())
}
/// Operator-visible connection-start timestamp for a pending handshake
/// `link`, read from the per-peer machine carrier (the timing's home now
/// that the leg no longer projects it). A link with no machine reports 0;
/// every leg surfaced by `connections()` is embedded in a machine, so the
/// lookup resolves.
pub(crate) fn connection_started_at(&self, link: LinkId) -> u64 {
self.peer_machines
.get(&link)
.map_or(0, |machine| machine.conn_started_at())
}
/// Operator-visible last-activity timestamp for a pending handshake `link`,
/// read from the per-peer machine carrier. A link with no machine reports 0;
/// every leg surfaced by `connections()` is embedded in a machine, so the
/// lookup resolves.
pub(crate) fn connection_last_activity(&self, link: LinkId) -> u64 {
self.peer_machines
.get(&link)
.map_or(0, |machine| machine.conn_last_activity())
}
/// Operator-visible handshake-state string for a pending handshake `link`,
/// derived from the per-peer control machine (the phase's home now that the
/// leg no longer carries it). Every leg surfaced by `connections()` is