diff options
| author | tv <tv@krebsco.de> | 2026-11-16 20:48:03 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-16 22:03:41 +0100 |
| commit | 0e1238015e55854515a4cbc6b6ef757792e7d804 (patch) | |
| tree | bc7c008dfdf36d78d1e80f10d03e13926690749e /src/federation | |
| parent | c534b25dbd94dc41731f98e4c4b2a170fe02c347 (diff) | |
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.
Diffstat (limited to 'src/federation')
| -rw-r--r-- | src/federation/held.rs | 23 |
1 files changed, 23 insertions, 0 deletions
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<BTreeSet<(String, String)>> { self.members.read_or_recover().clone() @@ -391,6 +396,8 @@ fn found(pin: &Id, root: &[u8], events: &BTreeMap<Id, Vec<u8>>) -> Option<Built> pub(crate) async fn run_worker(state: crate::state::AppState) { let mut changed = state.change_tx.subscribe(); let mut due: Option<tokio::time::Instant> = None; + // Whether this node is a member of its store, as last said. + let mut listed: Option<bool> = 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), |
