From 09b4f7daac52b5aa6cebaa9c147a9086b105aac9 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 01:59:38 +0100 Subject: access first users --- src/swarm/bootstrap.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/swarm') diff --git a/src/swarm/bootstrap.rs b/src/swarm/bootstrap.rs index 76e056d..a7266c7 100644 --- a/src/swarm/bootstrap.rs +++ b/src/swarm/bootstrap.rs @@ -91,8 +91,28 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start) // Plain names (kebab-case): serializing them can't fail. let topology = serde_json::to_value(state.configured_ways.0).unwrap_or_default(); let dissemination = serde_json::to_value(state.configured_ways.1).unwrap_or_default(); + // The first users, granted by this node: with the rest, so that no node sees the + // swarm without its registry (none named: none, as in a swarm from before). + let (by, since) = ( + state.local_id().to_owned(), + state.clock.now_millis().as_u64(), + ); + let users: Vec<(Vec, JsonValue)> = state + .first_users + .iter() + .map(|(name, admin)| { + let caps = crate::access::registry::first_caps(*admin); + ( + crate::access::registry::user_path(name), + crate::access::registry::entry(&by, since, &caps), + ) + }) + .collect(); state .mutate_doc(move |doc| { + for (path, entry) in &users { + store::write_path(doc, path, entry)?; + } store::write_path(doc, &swarm_id_path(), &recorded)?; store::write_path( doc, @@ -107,7 +127,9 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start) ) }) .await - .context("Recording the swarm ID, its neighbours, its topology and dissemination")?; + .context( + "Recording the swarm ID, its neighbours, its topology and dissemination, its first users", + )?; state.initial_sync_done.store(true, Ordering::Release); state.mark_ready(swarm_id).await?; // Remembered members, if any, to find those still running. -- cgit v1.3.1