From c301f7f3805b21fe811ee5201f8fe817274c33bb Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 22:00:37 +0200 Subject: remake coordinators resume after restart --- src/remake/local.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/remake/local.rs') diff --git a/src/remake/local.rs b/src/remake/local.rs index 0d6c6c7..04ac0b0 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -53,6 +53,8 @@ struct Inner { contents: HashMap<[u8; 32], (Arc>, Instant)>, /// Content being downloaded. content_fetches: HashSet<[u8; 32]>, + /// Remakes this node coordinates now (`coordinator`). + coordinating: HashSet, } /// Content no remake refers to any more is kept this long after it was stored, for @@ -145,6 +147,19 @@ impl RemakeState { self.started_at } + /// 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()) + } + + pub(crate) fn end_coordinating(&self, id: &str) { + self.lock().coordinating.remove(id); + } + + pub(crate) fn is_coordinating(&self, id: &str) -> bool { + self.lock().coordinating.contains(id) + } + fn lock(&self) -> MutexGuard<'_, Inner> { self.inner .lock() -- cgit v1.3.1