From 9164ebfe9a4014cbbaaaff90c5a1d722e39457fd Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 13:34:24 +0000 Subject: federation: which nodes know a revision, in counts and before a `true` `GET /events/counts` says, of each node a party lists, what it said it speaks and knows (`knows`, by node ID): the wire versions, the oldest and the newest, and the newest revision of the federation it knows, by number and ID and as people read it, its number null where this continuum doesn't know it; null where it said nothing, a build from before SPEAKS or one the node didn't hear from; the node's own as it is. So the nodes still to upgrade before a revision passes show, every party's, where before a party's operators could check only their own. A party's client, backing a proposal that moves to another revision, warns of every node of any party not known to know it, a line a party naming each and what it said: once it passes, those stop at it till upgraded. `next` warns alike, of the revision it moves to, or of the later one it suggests. A warning, not a refusal: what a node heard is no proof, and a node not heard from may well be upgraded. --- src/swarm/speaking.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/swarm') diff --git a/src/swarm/speaking.rs b/src/swarm/speaking.rs index dcbfac4..e1a8d2c 100644 --- a/src/swarm/speaking.rs +++ b/src/swarm/speaking.rs @@ -43,4 +43,30 @@ impl Speaking { } heard.insert(peer.to_owned(), speaks); } + + /// What `peer` said last, if it said anything. + pub(crate) fn of(&self, peer: &str) -> Option { + self.0.lock_or_recover().get(peer).copied() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_peer_is_heard_as_it_spoke_last() { + let speaking = Speaking::default(); + assert_eq!(speaking.of("a"), None); + speaking.heard("a", own()); + let older = Speaks { + oldest: 1, + newest: 1, + revision: None, + }; + speaking.heard("b", older); + speaking.heard("a", older); + assert_eq!(speaking.of("a"), Some(older)); + assert_eq!(own().newest, wire::VERSION); + } } -- cgit v1.3.1