From 2c9be74e184e0d942f03a8f1b549bdd7317e2dbd Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 Nov 2026 15:34:56 +0000 Subject: store: a party's next event builds on its last, past 64 heads Where a store holds more heads than an event names, a new event builds on the earliest. A party's write may then lack its last one in its history: of two neither in the other's the lower ID counts, not the later, and a key set written so is written under an older version, and ranks below one written under the latest. building_on_with names a head holding each event it is asked to hold, beside the one holding what the fold judges by; GET /events?party=NAME asks it for that party's last write, key set or node list (latest_of), and continuum-party signs on the heads for its party. --- src/federation/party.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/federation/party.rs') diff --git a/src/federation/party.rs b/src/federation/party.rs index c8f19ea..4420478 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -1464,7 +1464,7 @@ async fn sign( path: &Path, does: (&str, Json), ) -> Result<()> { - let (_, heads) = node.summary().await?; + let heads = node.heads_for(&signer.party).await?; let event = signer.sign(&heads, does)?; record.signed(&event); record.save(path).map_err(|why| anyhow!(why))?; @@ -2553,6 +2553,25 @@ impl Node { Ok(self.answer(response).await?.json().await?) } + /// The heads an event of `party` builds on: the node's, one holding the party's last + /// write, key set or node list among them (`GET /events?party=`), so that its next has + /// it in its history where the store holds more heads than an event names. A node + /// before 0.1.0 names its heads whoever asks. + async fn heads_for(&self, party: &str) -> Result> { + let response = self + .request(reqwest::Method::GET, "/events")? + .query(&[("party", party)]) + .send() + .await?; + let summary: JsonValue = self.answer(response).await?.json().await?; + Ok(summary["heads"] + .as_array() + .into_iter() + .flatten() + .filter_map(|id| id.as_str().and_then(Id::from_hex)) + .collect()) + } + /// The store's ID, and its heads. async fn summary(&self) -> Result<(Id, Vec)> { let summary = self.get("/events").await?; -- cgit v1.3.1