diff options
| author | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
| commit | 9c12bf2e8815dc9b42be62f1e1fd2932dd02938b (patch) | |
| tree | 09cd985fae9142a247a2285c755f9d002a2c7b30 /src/swarm/members.rs | |
| parent | f4b0a7c5159d418e22682d2bd7d413fb3587ca7f (diff) | |
use Automerge as Document instead of AutoCommit
This allows a lot of operations to drop mut.
Diffstat (limited to 'src/swarm/members.rs')
| -rw-r--r-- | src/swarm/members.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/swarm/members.rs b/src/swarm/members.rs index 9885750..b3e2084 100644 --- a/src/swarm/members.rs +++ b/src/swarm/members.rs @@ -23,7 +23,7 @@ use tracing::{debug, info, warn}; use crate::document::meta; use crate::document::store::{self, StoreError}; -use crate::document::{Document, Transactable}; +use crate::document::{Document, ReadDoc, Transactable}; use crate::state::AppState; pub(crate) fn members_dir() -> Vec<String> { @@ -37,7 +37,7 @@ pub(crate) fn member_path(pk: &str) -> Vec<String> { } /// Public keys of all registered members, sorted. -pub(crate) fn members(doc: &Document) -> Vec<String> { +pub(crate) fn members(doc: &impl ReadDoc) -> Vec<String> { let mut members = store::keys_at(doc, &members_dir()).unwrap_or_default(); members.sort(); members @@ -199,7 +199,7 @@ fn alive_path(pk: &str) -> Vec<String> { path } -fn millis_at(doc: &Document, path: &[String]) -> Option<u64> { +fn millis_at(doc: &impl ReadDoc, path: &[String]) -> Option<u64> { match store::read_path(doc, path) { Ok(Some(JsonValue::Number(number))) => number.as_u64(), _ => None, @@ -207,7 +207,7 @@ fn millis_at(doc: &Document, path: &[String]) -> Option<u64> { } /// When `pk` last said it is alive (Unix ms): its last renewal, or its registration. -pub(crate) fn alive_at(doc: &Document, pk: &str) -> Option<u64> { +pub(crate) fn alive_at(doc: &impl ReadDoc, pk: &str) -> Option<u64> { let mut since = member_path(pk); since.push("since".to_owned()); millis_at(doc, &alive_path(pk)).max(millis_at(doc, &since)) @@ -215,7 +215,7 @@ pub(crate) fn alive_at(doc: &Document, pk: &str) -> Option<u64> { /// The members that said they are alive within `window` before `now_ms` (sorted): the /// electorate of a remake (`remake::coordinator`). -pub(crate) fn electorate(doc: &Document, now_ms: u64, window: Duration) -> Vec<String> { +pub(crate) fn electorate(doc: &impl ReadDoc, now_ms: u64, window: Duration) -> Vec<String> { let oldest = now_ms.saturating_sub(window.as_millis() as u64); members(doc) .into_iter() |
