From bf896c2a604557a764e889b45e37dbe416c660ba Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 12:59:39 +0000 Subject: client: a record begun from the store's root casts on its first version A record casts nothing on the version current when it began, as a `true` sent before may be held back somewhere. A federation's first version is current from its start, so a record begun at a node casts nothing on it, and with every party's begun so, no proposal on it can pass. `continuum-party init PARTY --root FILE` begins a record from the file the store's swarm starts from, for a party that never voted in it (`Record::before`): nothing was sent before it, and it casts on every version, the first too. A node voting by itself takes such a record as its `--store-vote-record`. --- src/federation/client.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/federation/client.rs') diff --git a/src/federation/client.rs b/src/federation/client.rs index 85411fe..9834771 100644 --- a/src/federation/client.rs +++ b/src/federation/client.rs @@ -9,7 +9,9 @@ //! dead, as signed, so that once a checkpoint left them out nothing names its party as //! voting twice; and the events it signed besides, to sign again what a move refused. It //! is written before a vote is sent. A record begins on the version current then, and -//! casts nothing on it, as a `true` sent before it began may be held back somewhere. +//! casts nothing on it, as a `true` sent before it began may be held back somewhere; one +//! begun from the store's root by a party that never voted in it casts on every version, +//! as nothing was sent before it. use std::collections::{BTreeMap, BTreeSet}; use std::path::Path; @@ -133,7 +135,8 @@ pub(crate) struct Record { /// The store it is of, by ID. pub(crate) store: String, pub(crate) party: String, - /// The version current when it began, by hash: it casts nothing on it. + /// The version current when it began, by hash: it casts nothing on it. Empty for one + /// begun from the store's root. pub(crate) began: String, /// The versions it voted on, by hash, each as its JCS text. #[serde(default)] @@ -212,10 +215,19 @@ fn dead_by(on: &Version, proposal: &Id, nays: &[Vec]) -> bool { impl Record { /// A record of `party` of the store `store`, beginning on `current`. pub(crate) fn begin(store: Id, party: &str, current: &Version) -> Self { + Record { + began: current.hash.to_string(), + ..Record::before(store, party) + } + } + + /// A record of `party` of the store `store`, begun from its root by a party that never + /// voted in it: it casts on every version. + pub(crate) fn before(store: Id, party: &str) -> Self { Record { store: store.to_string(), party: party.to_owned(), - began: current.hash.to_string(), + began: String::new(), versions: BTreeMap::new(), votes: Vec::new(), nays: Vec::new(), @@ -508,7 +520,8 @@ mod tests { .may_vote(¤t, one.hash(), &one.json(), true, &[]) .is_err() ); - record.began = Id::of(b"earlier").to_string(); + // Begun from the root: it casts on the first version. + record = Record::before(root, "tv"); assert_eq!( record.may_vote(¤t, one.hash(), &one.json(), true, &[]), Ok(Vec::new()) -- cgit v1.3.1