diff options
| -rw-r--r-- | docs/operations.md | 13 | ||||
| -rw-r--r-- | src/config/mod.rs | 1 | ||||
| -rw-r--r-- | src/document/mod.rs | 6 | ||||
| -rw-r--r-- | src/federation/party.rs | 2 | ||||
| -rw-r--r-- | src/lib.rs | 1 | ||||
| -rw-r--r-- | src/release.rs | 65 |
6 files changed, 88 insertions, 0 deletions
diff --git a/docs/operations.md b/docs/operations.md index 0502782..97fee26 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -109,6 +109,19 @@ how to upgrade to it from the release before: Before 1.0.0, any release may be a flag day; its tag's message says whether it is. +What decides which builds work together, a build says (`-V` the release alone): the wire +versions it speaks, the federation and the revisions of it it knows (with the +`federation` feature), and the Automerge it makes documents with. `continuum-party +--version` says the same. + +```sh +continuum --version +# continuum 1.0.0 +# wire versions 52 to 52 +# federation 1: the base revision, revision 1 (merge-events) +# automerge 0.12.0 +``` + A node upgrades by restarting with its files. What to know: * **The wire format.** Each change to it bumps a version byte, and nodes ignore diff --git a/src/config/mod.rs b/src/config/mod.rs index a1e6328..3b8d305 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1876,6 +1876,7 @@ pub(super) const UNSET: &str = "unset"; fn command() -> Command { let command = Command::new("continuum") .version(env!("CARGO_PKG_VERSION")) + .long_version(crate::release::described()) .about("continuum: a replicated Automerge document over Mycelium, libp2p or Tor") .arg( Arg::new(PRINT_CONFIG) diff --git a/src/document/mod.rs b/src/document/mod.rs index e548d01..530e6b6 100644 --- a/src/document/mod.rs +++ b/src/document/mod.rs @@ -13,6 +13,12 @@ pub(crate) use automerge::{ ScalarValue, }; +/// The version of Automerge this build makes documents with: a remake needs the same on +/// every node, and a federation the same encoding of a change (`remake::snapshot`). +pub(crate) fn engine_version() -> &'static str { + Document::new().stats().cargo_package_version +} + /// How many writers (actors) `doc`'s changes have: from the changes' metadata, in /// time proportional to the document. pub(crate) fn writers(doc: &Document) -> usize { diff --git a/src/federation/party.rs b/src/federation/party.rs index 2c8dc4b..d829cc9 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -81,6 +81,8 @@ fn default_node() -> String { fn command() -> Command { let id = |name: &'static str| Arg::new(name).required(true); let command = Command::new("continuum-party") + .version(env!("CARGO_PKG_VERSION")) + .long_version(crate::release::described()) .about("A party's client of a federation: signs its events, and votes by its record"); config::with_options(command, config::PARTY_OPTIONS) .subcommand_required(true) @@ -28,6 +28,7 @@ mod identity; mod locks; mod logging; mod node; +mod release; mod remake; #[cfg(test)] mod simtest; diff --git a/src/release.rs b/src/release.rs new file mode 100644 index 0000000..fe0df3b --- /dev/null +++ b/src/release.rs @@ -0,0 +1,65 @@ +//! What this build of continuum is, as `--version` says it: its release, the wire versions +//! it speaks, the federation and the revisions of it it knows, and the Automerge it makes +//! documents with; what decides which builds work together in one swarm +//! (`docs/operations.md`, Upgrading). Its peers say theirs with their handshakes +//! (`swarm::speaking`). + +use std::sync::OnceLock; + +use crate::transport::wire; + +/// What `--version` says after the program's name: the release, then a line each. +pub(crate) fn described() -> &'static str { + static DESCRIBED: OnceLock<String> = OnceLock::new(); + DESCRIBED.get_or_init(|| { + let mut lines = vec![ + env!("CARGO_PKG_VERSION").to_owned(), + format!("wire versions {} to {}", wire::OLDEST, wire::VERSION), + ]; + lines.extend(federation()); + lines.push(format!("automerge {}", crate::document::engine_version())); + lines.join("\n") + }) +} + +/// The federation this build knows, and its revisions, the base revision first. +#[cfg(feature = "federation")] +fn federation() -> Option<String> { + use crate::federation::revision::Revision; + let revisions: Vec<String> = Revision::known() + .map(|revision| revision.to_string()) + .collect(); + Some(format!( + "federation {}: {}", + crate::federation::version::FEDERATION, + revisions.join(", ") + )) +} + +#[cfg(not(feature = "federation"))] +fn federation() -> Option<String> { + None +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_build_says_what_decides_whom_it_works_with() { + let lines: Vec<&str> = described().lines().collect(); + assert_eq!(lines[0], env!("CARGO_PKG_VERSION")); + assert_eq!( + lines[1], + format!("wire versions {} to {}", wire::OLDEST, wire::VERSION) + ); + #[cfg(feature = "federation")] + assert!( + lines[2].starts_with("federation 1: the base revision"), + "{}", + lines[2] + ); + let automerge = lines.last().expect("lines"); + assert!(automerge.starts_with("automerge 0."), "{automerge}"); + } +} |
