diff options
| author | tv <tv@krebsco.de> | 2026-11-03 06:32:25 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-03 06:32:25 +0100 |
| commit | 0617951a2936a8dd7c64eb05a3605893cc9d73f1 (patch) | |
| tree | 6e087759e6f5f58d1e022becb55cf0c0ec87c6b3 /src/swarm/reach.rs | |
| parent | 0d340dbcf4a3fc7c5d16ab52d3c40eb412c5da67 (diff) | |
reach set for the session
Diffstat (limited to 'src/swarm/reach.rs')
| -rw-r--r-- | src/swarm/reach.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/swarm/reach.rs b/src/swarm/reach.rs index 17b189d..901b47c 100644 --- a/src/swarm/reach.rs +++ b/src/swarm/reach.rs @@ -8,9 +8,11 @@ //! STATUS_REPLY, and soon (the peer worker looks every 5 s) to every neighbour when it //! changed, //! but not in announcements of heads, which go often. So every node knows whom its -//! neighbours reach, as of their latest STATUS: for as long as that is fresh -//! (`held_for`), then not, until the next. Nothing goes into the document, and nobody -//! knows more than two hops out. +//! neighbours reach, as of their latest STATUS, for as long as the session lasts (a +//! neighbour that goes dormant, or starts anew, says it again). Not for a set time: +//! while a pair exchanges changes it sends no keepalives, and so no STATUS, for as +//! long as the writes go on. Nothing goes into the document, and nobody knows more than +//! two hops out. //! //! What it is for: passing changes on around links that don't work, and to exactly the //! members the sender doesn't reach; a member a neighbour reaches is one worth trying, @@ -20,7 +22,6 @@ //! nothing but in a full mesh. use std::collections::HashMap; -use std::time::Duration; use tokio::time::Instant; use tracing::debug; @@ -96,17 +97,10 @@ async fn tell(state: &AppState, peer: &str) -> anyhow::Result<()> { announce_heads(state, peer, true).await } -/// How long what a neighbour said it reaches holds: past two of its regular STATUSes, -/// each of which says it again. -pub(crate) fn held_for(state: &AppState) -> Duration { - state.timing.status_refresh * 2 + state.timing.keepalive -} - -/// The members `peer` reaches, as it last said, while that holds (`held_for`); by -/// pair key. -pub(crate) fn of(state: &AppState, said: Option<&(Instant, Vec<u64>)>) -> Option<Vec<u64>> { - said.filter(|(at, _)| at.elapsed() < held_for(state)) - .map(|(_, reaches)| reaches.clone()) +/// The members a peer reaches, as it last said in this session (`said`, kept with its +/// state, cleared when the session ends: `PeerState::reset_sync`); by pair key. +pub(crate) fn of(said: Option<&(Instant, Vec<u64>)>) -> Option<Vec<u64>> { + said.map(|(_, reaches)| reaches.clone()) } /// The members of our member list by pair key, to name what neighbours say they reach. |
