From 0e1238015e55854515a4cbc6b6ef757792e7d804 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 20:48:03 +0000 Subject: peer: in a swarm holding a store, its members only A node of a swarm holding a store syncs with its members only (`docs/store.md`, Members): the nodes its store names, each with the party its handshakes name, as the store reads now. A handshake from any other goes unanswered, and what the node had with it ends, as with a banned node; so does what it had with a member at its next message, once the store names it no more (`swarm::peer::members`). The party a handshake names is kept with the peer. While a node holds no store yet, joining, it can't tell, and takes everyone of its swarm: its seeds, which take it only where its party lists it. A node says whether it is a member itself, as its store reads, when that changes. --- src/federation/held.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/federation') diff --git a/src/federation/held.rs b/src/federation/held.rs index 5b9a740..fe8b6a9 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -337,6 +337,11 @@ impl Holding { Some(party.is_some_and(|party| members.contains(&(node.to_owned(), party.to_owned())))) } + /// Whether the node holds a store, and so tells who is a member (`member`). + pub(crate) fn tells_members(&self) -> bool { + self.members.read_or_recover().is_some() + } + /// The members the store names, each with its party, while the node holds a store. pub(crate) fn members(&self) -> Option> { self.members.read_or_recover().clone() @@ -391,6 +396,8 @@ fn found(pin: &Id, root: &[u8], events: &BTreeMap>) -> Option pub(crate) async fn run_worker(state: crate::state::AppState) { let mut changed = state.change_tx.subscribe(); let mut due: Option = None; + // Whether this node is a member of its store, as last said. + let mut listed: Option = None; let mut looks = tokio::time::interval(LOOK); looks.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); let mut look = false; @@ -423,6 +430,22 @@ pub(crate) async fn run_worker(state: crate::state::AppState) { error!(error = %error, "Reading the store from the document failed"); false }); + let member = state + .holding + .member(state.local_id(), state.holding.party()); + if member.is_some() && member != listed { + match member { + Some(false) => warn!( + party = state.holding.party(), + "This node isn't a member of its store, as it reads now: its party doesn't list it, and members don't sync with it" + ), + _ => info!( + party = state.holding.party(), + "This node is a member of its store" + ), + } + listed = member; + } due = match due { _ if !lacking => None, Some(due) => Some(due), -- cgit v1.3.1