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/party.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/federation/party.rs') diff --git a/src/federation/party.rs b/src/federation/party.rs index ecd75a9..cb9eb54 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -4,7 +4,9 @@ //! keeps its party's record (`--record`, `client::Record`), by which it votes, written //! before a vote is sent. //! -//! * `init PARTY`: begins a record of `PARTY`, on the version current now; +//! * `init PARTY`: begins a record of `PARTY`, on the version current now; with `--root +//! FILE`, from the file the store's swarm starts from, for a party that never voted in +//! it: the record casts on every version, the first too; //! * `write PATH VALUE`: writes `VALUE` (JSON) at `PATH`; //! * `keys KEY...`, `nodes NODE...`: writes the party's key set (`authorized_keys` lines) //! or node list (node IDs); @@ -76,7 +78,13 @@ fn command() -> Command { .subcommand( Command::new("init") .about("Begins a record") - .arg(id("party")), + .arg(id("party")) + .arg( + Arg::new("root") + .long("root") + .value_name("FILE") + .help("From the file the store's swarm starts from, for a party that never voted in it"), + ), ) .subcommand( Command::new("write") @@ -224,10 +232,22 @@ pub(crate) async fn main() -> Result<()> { bail!("{} holds a record already", path.display()); } let party = sub.get_one::("party").expect("required"); - let (store, _) = node.summary().await?; - let record = Record::begin(store, party, &node.current().await?); + let record = match sub.get_one::("root") { + Some(file) => { + let bytes = std::fs::read(file).with_context(|| format!("Reading {file}"))?; + let (root, kept) = super::fork::read_root_file(&bytes); + if let Err(refused) = Store::::new(root.clone(), kept) { + bail!("no store's root: {}", refused.0); + } + Record::before(Id::of(&root), party) + } + None => { + let (store, _) = node.summary().await?; + Record::begin(store, party, &node.current().await?) + } + }; record.save(&path).map_err(|why| anyhow!(why))?; - println!("began a record of {party}, of the store {store}"); + println!("began a record of {party}, of the store {}", record.store); return Ok(()); } let mut record = Record::load(&path).map_err(|why| anyhow!(why))?; -- cgit v1.3.1