From f9b456c540226f6ba30b508146448c1d35990883 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 22:26:45 +0000 Subject: continuum-party: a vote through the node that votes for the party A party that has a node vote by itself votes by hand only through that node: `continuum-party vote PROPOSAL yes|no --through` asks the node to cast it (`POST /admin/events/vote`), by the record the node keeps, without a key or record of the client's own. --- src/federation/party.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/federation') diff --git a/src/federation/party.rs b/src/federation/party.rs index 8163fb3..d5fcb2c 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -10,7 +10,8 @@ //! or node list (node IDs); //! * `propose FILE`: proposes the version `FILE` holds (JSON); //! * `vote PROPOSAL yes|no`: votes on the proposal of hash `PROPOSAL` on the current -//! version, by the record; +//! 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; //! * `again`: signs again what a move refused; //! * `twice RECORD...`: names, from the records of parties' clients, a party that voted //! twice. @@ -92,7 +93,13 @@ fn command() -> Command { Command::new("vote") .about("Votes on a proposal on the current version, by its hash") .arg(id("proposal")) - .arg(Arg::new("yes").required(true).value_parser(["yes", "no"])), + .arg(Arg::new("yes").required(true).value_parser(["yes", "no"])) + .arg( + Arg::new("through") + .long("through") + .action(ArgAction::SetTrue) + .help("Through the node, which votes for the party and keeps its record"), + ), ) .subcommand(Command::new("again").about("Signs again what a move refused")) .subcommand( @@ -124,6 +131,19 @@ pub(crate) async fn main() -> Result<()> { return Ok(()); } let node = Node::new(&matches)?; + // A party that has a node vote by itself votes by hand only through it. + if name == "vote" && sub.get_flag("through") { + let proposal = sub.get_one::("proposal").expect("required"); + let yes = sub.get_one::("yes").map(String::as_str) == Some("yes"); + let answer = node + .post( + "/admin/events/vote", + &serde_json::json!({"proposal": proposal, "yes": yes}), + ) + .await?; + println!("{} cast", answer["id"].as_str().unwrap_or_default()); + return Ok(()); + } let path = PathBuf::from( matches .get_one::("record") @@ -433,6 +453,15 @@ impl Node { Ok(bytes) } + async fn post(&self, path: &str, body: &JsonValue) -> Result { + let response = self + .request(reqwest::Method::POST, path)? + .json(body) + .send() + .await?; + Ok(Self::answer(response).await?.json().await?) + } + async fn put(&self, event: &[u8]) -> Result<()> { let response = self .request(reqwest::Method::POST, "/events")? -- cgit v1.3.1