diff options
| author | tv <tv@krebsco.de> | 2026-10-24 22:00:37 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 22:00:37 +0200 |
| commit | c301f7f3805b21fe811ee5201f8fe817274c33bb (patch) | |
| tree | 838b70e3074793e25ca6b5271d5684a033e150b4 /src/remake/local.rs | |
| parent | 4953dacb654f195cf0ad04f2560fddcaab6dbf7d (diff) | |
remake coordinators resume after restart
Diffstat (limited to 'src/remake/local.rs')
| -rw-r--r-- | src/remake/local.rs | 15 |
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() |
