From 63b34dfa41e1595145507a88901e332bf4bd3b14 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 22:35:21 +0100 Subject: signatures: kept in the document file A node's signatures are saved with its document (--document-file) and loaded with it. Auth plan M5. --- src/swarm/bootstrap.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/swarm/bootstrap.rs') diff --git a/src/swarm/bootstrap.rs b/src/swarm/bootstrap.rs index 446b846..10ad412 100644 --- a/src/swarm/bootstrap.rs +++ b/src/swarm/bootstrap.rs @@ -241,6 +241,8 @@ pub(crate) struct StartingDocument { pub(crate) origin: Origin, /// The actors this node wrote with before (from the document file). pub(crate) earlier_actors: Vec, + /// The signatures of its changes (from the document file). + pub(crate) signatures: Vec<(crate::document::ChangeHash, [u8; 64])>, } /// What `--recover-from` and `--document-file` say about where to start. @@ -289,7 +291,7 @@ pub(crate) fn starting_document( Some(path) => Some(load_backup(path, files)?), }; - let (doc, origin, earlier_actors) = match (backup, from_file) { + let (doc, origin, earlier_actors, signatures) = match (backup, from_file) { (Some(_), Some(_)) if !force.allows("replaceDocumentFile") => { bail!( "recover-from would replace the document in the document file; add --force replaceDocumentFile to recover the backup anyway" @@ -301,9 +303,14 @@ pub(crate) fn starting_document( "Recovering the backup instead of the document file's document (--force replaceDocumentFile)" ); } - (backup, Origin::Backup, Vec::new()) + (backup, Origin::Backup, Vec::new(), Vec::new()) } - (None, Some(loaded)) => (loaded.doc, Origin::DocumentFile, loaded.actors), + (None, Some(loaded)) => ( + loaded.doc, + Origin::DocumentFile, + loaded.actors, + loaded.signatures, + ), (None, None) => return Ok(None), }; if options.genesis && origin == Origin::DocumentFile { @@ -311,7 +318,8 @@ pub(crate) fn starting_document( "The document file holds a document of a swarm, and genesis would start a new one; move the file away to start a new swarm" ); } - let starting = identify(doc, origin, earlier_actors)?; + let mut starting = identify(doc, origin, earlier_actors)?; + starting.signatures = signatures; if let Some(remembered) = options.remembered.filter(|id| *id != starting.swarm_id) { let what = origin.describe(); @@ -347,6 +355,7 @@ fn identify( swarm_id, origin, earlier_actors, + signatures: Vec::new(), }) } -- cgit v1.3.1