aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 02:48:25 +0000
committertv <tv@krebsco.de>2026-11-29 02:48:25 +0000
commit8a29efed857991417d12b8e21884dbbcb53ff4a0 (patch)
treef57da52ac22090146c3f3baac23fb0b5dd2938dc /src/state
parentb259ee75fbbbf8e265a0bf2a0b79c4f6a75f395a (diff)
document: the writers a node wrote under are the document's, not a remake's
The actors a node writes or wrote with in its current document (document::own::OwnWriters, AppState::own_writers) were kept by the remake state, which signing, the document file, sync and a dropped change read them from. They are the engine's: a document of a kind without writers of this sort has none, and needs no remake state for them.
Diffstat (limited to 'src/state')
-rw-r--r--src/state/host.rs14
-rw-r--r--src/state/mod.rs3
2 files changed, 12 insertions, 5 deletions
diff --git a/src/state/host.rs b/src/state/host.rs
index 0b2b27d..34ed7ed 100644
--- a/src/state/host.rs
+++ b/src/state/host.rs
@@ -30,7 +30,7 @@ impl AppState {
replica.signatures = replica.signatures.kept_for(&replica.doc);
if let Some(key) = &self.node_key {
let replica = &mut *replica;
- let own = self.remake.own_actors();
+ let own = self.own_writers.all();
replica
.signatures
.sign_own_actors(&mut replica.doc, key, &own);
@@ -110,7 +110,7 @@ impl AppState {
/// of the document (past `SMALL_DROP`), wait for another's.
const BIG_DROP: usize = 100;
const SMALL_DROP: usize = 10;
- let own = self.remake.own_actors();
+ let own = self.own_writers.all();
// Another member to hear it from: a node with one neighbour, the one telling, has
// only its word (a swarm of two, a leaf), and waiting would hold the drop for good.
let another = crate::swarm::topology::our_neighbours(self)
@@ -221,7 +221,7 @@ impl AppState {
},
})
.collect();
- state.remake.add_own_actor(actor);
+ state.own_writers.add(actor);
let epoch = replica.epoch;
let old = state.swap_document(&mut replica, epoch, fresh);
{
@@ -297,6 +297,10 @@ impl Host for AppState {
&self.remake
}
+ fn own_writers(&self) -> &crate::document::own::OwnWriters {
+ &self.own_writers
+ }
+
fn clock(&self) -> Arc<crate::clock::Clock> {
Arc::clone(&self.clock)
}
@@ -533,7 +537,7 @@ impl Host for AppState {
// What it replayed, vouched for at once.
if let Some(key) = &state.node_key {
let replica = &mut *replica;
- let own = state.remake.own_actors();
+ let own = state.own_writers.all();
replica
.signatures
.sign_own_actors(&mut replica.doc, key, &own);
@@ -617,7 +621,7 @@ impl Host for AppState {
)
.map(|outcome| {
if let Some(actor) = outcome.fresh_actor {
- state.remake.add_own_actor(actor);
+ state.own_writers.add(actor);
}
})
.map_err(|error| format!("{error:#}"))
diff --git a/src/state/mod.rs b/src/state/mod.rs
index a812b91..4187654 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -111,6 +111,9 @@ pub(crate) struct AppState {
/// Per-node remake state (prebuilt snapshots, switch status, archive).
pub(crate) remake: Arc<RemakeState>,
+ /// The writers this node writes or wrote under in its current document.
+ pub(crate) own_writers: Arc<crate::document::own::OwnWriters>,
+
/// Pre-shared key every member must prove in the handshake; None admits any node
/// that reaches us.
pub(crate) swarm_key: Option<Arc<crate::swarm::auth::SwarmKey>>,