diff options
| author | tv <tv@krebsco.de> | 2026-10-26 05:54:53 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 05:54:53 +0100 |
| commit | 0b13e180c4dcd38e3ea8ffeecc9e5ebefa023212 (patch) | |
| tree | 7ab995f1a8d6aed9365bd6eed5fe2625fd56324e /src/state | |
| parent | f00378e8609e0117132d7aab3f4468a1721f52fa (diff) | |
number handshakes
This prevents late hellos from resetting the session.
Diffstat (limited to 'src/state')
| -rw-r--r-- | src/state/mod.rs | 2 | ||||
| -rw-r--r-- | src/state/peer.rs | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs index 438ad52..a51339c 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -85,6 +85,8 @@ pub(crate) struct AppState { /// Random per run of this node; our HELLOs carry it and replies must echo it. pub(crate) run_id: transport::RunId, + /// Handshakes this node started in this run, with any peer (`HelloRequest::handshake`). + pub(crate) handshakes: Arc<std::sync::atomic::AtomicU32>, /// Target number of neighbours (`--neighbours`); up to this many + 1 members the /// swarm is a full mesh. diff --git a/src/state/peer.rs b/src/state/peer.rs index e96cd9c..2ac6b1a 100644 --- a/src/state/peer.rs +++ b/src/state/peer.rs @@ -102,6 +102,11 @@ pub(crate) struct PeerState { pub(crate) epoch_seq: Option<u32>, /// The peer's run, from its HELLO or HELLO_REPLY: a new one starts `epoch_seq` over. pub(crate) run_id: Option<crate::transport::RunId>, + /// The newest handshake the peer started with us: its run and number + /// (`HelloRequest::handshake`). A HELLO repeating it is a retry or a late copy. + pub(crate) last_hello: Option<(crate::transport::RunId, u32)>, + /// The number of our current handshake with the peer (`AppState::handshakes`). + pub(crate) handshake: u32, /// Whether the peer was ready according to its most recent sync message or keepalive. pub(crate) reports_ready: Option<bool>, @@ -169,6 +174,8 @@ impl PeerState { epoch: None, epoch_seq: None, run_id: None, + last_hello: None, + handshake: 0, reports_ready: None, syncs_with_us: None, reported_heads: None, |
