aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/party.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-25 15:34:56 +0000
committertv <tv@krebsco.de>2026-11-25 15:34:56 +0000
commit2c9be74e184e0d942f03a8f1b549bdd7317e2dbd (patch)
tree52170b9d4d3ba7dd1a9cb4db01830b84b38bf40b /src/federation/party.rs
parente22f2e5c38baa1866793338fc7abde8c8e53b635 (diff)
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.
Diffstat (limited to 'src/federation/party.rs')
-rw-r--r--src/federation/party.rs21
1 files changed, 20 insertions, 1 deletions
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<Vec<Id>> {
+ 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<Id>)> {
let summary = self.get("/events").await?;