aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 19:44:37 +0000
committertv <tv@krebsco.de>2026-11-16 21:25:59 +0100
commit0ba4c7363cfa2a9963ecd6a06392ea5c4dac3ad1 (patch)
treefa40cfbfda010601eff9f9db148c5aa793aca0b2 /src/main.rs
parent3fccc4f6859cf0b4d93e7d166142e1ab9255723f (diff)
node: a swarm holding a store, started from its root or joined by its ID
Behind the `federation` feature, two options: * `--store-root PATH` starts a swarm holding a store, or goes on with one, from the store's root, as bytes in the file, which the federation must take as a root. With no document to start on, the node builds the genesis change from it, as every node given the root does, and is ready at once; a document to start on must be of the root's swarm. * `--store-id ID` joins one through seeds by its ID, the root's SHA-256 in hex. An empty document of the first epoch takes as its root only that store's genesis change, built again from the root it holds (`document::events::is_genesis`), whatever peers name: the root pin doesn't wait for seeds, nor is disputed. Either names the swarm the node joins, which a state file must remember too, and can't be combined with the other, nor with what makes a new swarm's first change (`--genesis`, `--bootstrap-users`, `--bootstrap-keys`, `--bootstrap-policy`, `--remake`, `--genesis-root`). The root is read as a file of its own kind (`store`), counted among the node's files.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 6d0d82f..d074475 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -173,6 +173,17 @@ async fn main() -> Result<()> {
&files,
&force,
)?;
+ // A swarm holding a store: started from its root, or joined by its ID.
+ #[cfg(feature = "federation")]
+ let store =
+ bootstrap::StoreStart::of(args.store_root.as_deref(), args.store_id.as_deref(), &files)?;
+ #[cfg(feature = "federation")]
+ let starting = match &store {
+ Some(store) => {
+ store.starting(starting, remembered.as_ref().map(|r| r.swarm_id.as_str()))?
+ }
+ None => starting,
+ };
let (
initial_doc,
starting_epoch,
@@ -298,6 +309,8 @@ async fn main() -> Result<()> {
session_lifetime: args.session_lifetime,
challenge_lifetime: args.challenge_lifetime,
genesis_root: args.genesis_root.as_deref().and_then(swarm::roots::parse),
+ #[cfg(feature = "federation")]
+ store: store.as_ref().map(|store| store.id),
strict_keys: args
.strict_keys
.iter()
@@ -322,8 +335,11 @@ async fn main() -> Result<()> {
bootstrap::Start::FromDocument(origin)
}
None => {
- if let Some(remembered) = remembered {
- state.set_expected_swarm_id(remembered.swarm_id).await?;
+ let expected = remembered.map(|remembered| remembered.swarm_id);
+ #[cfg(feature = "federation")]
+ let expected = expected.or_else(|| store.as_ref().map(bootstrap::StoreStart::swarm_id));
+ if let Some(expected) = expected {
+ state.set_expected_swarm_id(expected).await?;
}
if args.genesis {
bootstrap::Start::Genesis