aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/reach.rs24
-rw-r--r--src/swarm/tree.rs2
2 files changed, 10 insertions, 16 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.
diff --git a/src/swarm/tree.rs b/src/swarm/tree.rs
index ee46271..8031a69 100644
--- a/src/swarm/tree.rs
+++ b/src/swarm/tree.rs
@@ -125,7 +125,7 @@ pub(crate) async fn plan(state: &AppState, writer: u64) -> Option<Plan> {
reaches.insert(me, reach::published(state));
for member in graph.get(me).into_iter().flatten() {
if let Some(peer_state) = state.get_peer_state(member).await
- && let Some(keys) = reach::of(state, peer_state.lock().await.reaches.as_ref())
+ && let Some(keys) = reach::of(peer_state.lock().await.reaches.as_ref())
{
reaches.insert(member.as_str(), keys);
}