summaryrefslogtreecommitdiffstats
path: root/src/remake/local.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-24 22:00:37 +0200
committertv <tv@krebsco.de>2026-10-24 22:00:37 +0200
commit326c25618eb0a2e77b98f7efe933d7f74fb32dc0 (patch)
treec4c6f5a909a508e775f9312160e89eddc326ba71 /src/remake/local.rs
parenta1994d3b75a28dbada75fafb7a0f62c0d0267ccd (diff)
remake coordinators resume after restart
Diffstat (limited to 'src/remake/local.rs')
-rw-r--r--src/remake/local.rs15
1 files changed, 15 insertions, 0 deletions
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<Vec<u8>>, Instant)>,
/// Content being downloaded.
content_fetches: HashSet<[u8; 32]>,
+ /// Remakes this node coordinates now (`coordinator`).
+ coordinating: HashSet<String>,
}
/// 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()