From 866924934d635df8a8f222a022f806c44581a5f5 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 25 Oct 2026 19:55:59 +0100 Subject: nodes keep list of every actor ID they've used --- src/remake/local.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/remake/local.rs') diff --git a/src/remake/local.rs b/src/remake/local.rs index 04ac0b0..09c99bd 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -9,7 +9,7 @@ use std::collections::{HashMap, HashSet}; use std::sync::{Arc, Mutex, MutexGuard}; use std::time::Duration; -use automerge::AutoCommit; +use automerge::{ActorId, AutoCommit}; use serde::Serialize; use tokio::time::Instant; @@ -55,6 +55,9 @@ struct Inner { content_fetches: HashSet<[u8; 32]>, /// Remakes this node coordinates now (`coordinator`). coordinating: HashSet, + /// Every actor this node writes or wrote with: one per run and epoch, and those of + /// earlier runs it knows of (`--document-file`). Its own writes, for a rejoin. + own_actors: Vec, } /// Content no remake refers to any more is kept this long after it was stored, for @@ -147,6 +150,18 @@ impl RemakeState { self.started_at } + /// This node writes with `actor` from now on (or did, in an earlier run). + pub(crate) fn add_own_actor(&self, actor: ActorId) { + let mut inner = self.lock(); + if !inner.own_actors.contains(&actor) { + inner.own_actors.push(actor); + } + } + + pub(crate) fn own_actors(&self) -> Vec { + self.lock().own_actors.clone() + } + /// Whether this node starts coordinating `id` now (false if it already does). pub(crate) fn start_coordinating(&self, id: &str) -> bool { self.lock().coordinating.insert(id.to_owned()) -- cgit v1.3.1