diff options
Diffstat (limited to 'src/federation/party.rs')
| -rw-r--r-- | src/federation/party.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/federation/party.rs b/src/federation/party.rs index 99a95be..43b2cba 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -15,7 +15,8 @@ //! * `next`: the version after the current one, to change and propose: the current one //! numbered on, naming its hash, without its checkpoint (JSON), to standard output; //! * `propose FILE`: proposes the version `FILE` holds (JSON), where it changes the -//! current one as a version must (`Version::changes_validly`); +//! current one as a version must (`Version::changes_validly`), and says the proposal's +//! hash; with `--yes`, votes `true` on it too, as `vote` does; //! * `vote PROPOSAL yes|no`: votes on the proposal of hash `PROPOSAL` on the current //! version, by the record; with `--through`, through the node that votes for the //! party by itself and keeps its record, as such a party votes by hand; @@ -108,8 +109,14 @@ fn command() -> Command { )) .subcommand( Command::new("propose") - .about("Proposes the version a file holds (JSON)") - .arg(id("file")), + .about("Proposes the version a file holds (JSON), and says the proposal's hash") + .arg(id("file")) + .arg( + Arg::new("yes") + .long("yes") + .action(ArgAction::SetTrue) + .help("Votes true on it too, by the record, as vote does"), + ), ) .subcommand( Command::new("vote") @@ -310,8 +317,8 @@ pub(crate) async fn main() -> Result<()> { ("propose", sub) => { let version = version_in(sub.get_one::<String>("file").expect("required"))?; let current = node.current().await?; - Version::read(&version) - .and_then(|proposed| proposed.changes_validly(Some(¤t))) + let proposed = Version::read(&version) + .and_then(|proposed| proposed.changes_validly(Some(¤t)).map(|()| proposed)) .map_err(|why| { anyhow!("not a version changing version {}: {why}", current.number) })?; @@ -322,7 +329,12 @@ pub(crate) async fn main() -> Result<()> { &path, event::proposal(&version), ) - .await + .await?; + println!("proposal {}", proposed.hash); + if sub.get_flag("yes") { + vote(&node, &signer, &mut record, &path, proposed.hash, true).await?; + } + Ok(()) } ("vote", sub) => { let proposal = Id::from_hex(sub.get_one::<String>("proposal").expect("required")) |
