diff options
| author | tv <tv@krebsco.de> | 2026-11-07 22:35:10 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-07 22:35:10 +0100 |
| commit | 7c6716358503abee5fab960c45e5fc2de5f61203 (patch) | |
| tree | 443fd7be1ecbe689bc3f8ca18c32b31e54639b81 /src/api | |
| parent | 8391a6df59d566ffd7de01560c262d1afdd8d43d (diff) | |
dashboard: the writers' trees as this node knows them
The tree drawn is computed as every node computes its own part of it:
from the member list, and whom it and its neighbours reach, as they
told it; no longer from the links members report over LINKS.
Auth plan M3 (preparing LINKS' removal).
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/dashboard/mod.rs | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs index 7d940c9..e86475f 100644 --- a/src/api/dashboard/mod.rs +++ b/src/api/dashboard/mod.rs @@ -715,41 +715,16 @@ struct TreeQuery { writer: String, } -/// `GET /admin/dashboard/tree?writer=…`: the writer's tree (`swarm::tree`), as this node -/// computes it from the member list and the links members report (whom each reaches, -/// and how far: its round trip, as a bucket, `rtt::bucket`; one that reports none counts -/// as reaching its neighbours by the member list): every member's parent, `null` for -/// one without. `404` if the writer isn't a member. +/// `GET /admin/dashboard/tree?writer=…`: the writer's tree (`swarm::tree::whole`), as +/// this node computes it: from the member list, and whom it and its neighbours reach +/// and how far, as they said (others as reaching their neighbours by the member list): +/// every member's parent, `null` for one without. `404` if the writer isn't a member. async fn writer_tree( Extension(hub): Extension<Arc<Hub>>, Query(query): Query<TreeQuery>, ) -> Response { let state = &hub.state; - let mut reports: BTreeMap<String, Vec<Link>> = state - .links - .replies() - .into_iter() - .map(|(member, _, links)| (member, links)) - .collect(); - reports.insert(state.local_id().to_owned(), links::own_links(state).await); - let reaches: BTreeMap<&str, BTreeSet<String>> = reports - .iter() - .map(|(member, links)| (member.as_str(), reached_by(links))) - .collect(); - let reached = |by: &str, member: &str| { - reaches - .get(by) - .is_none_or(|reached| reached.contains(member)) - }; - let round_trip = |by: &str, member: &str| { - let rtt = reports - .get(by) - .and_then(|links| links.iter().find(|link| link.peer == member)) - .and_then(|link| link.rtt_us) - .map(|us| std::time::Duration::from_micros(u64::from(us))); - crate::swarm::rtt::bucket(rtt, None) - }; - match crate::swarm::tree::whole(state, &query.writer, &reached, &round_trip) { + match crate::swarm::tree::whole(state, &query.writer).await { Some(parents) => { axum::Json(json!({ "writer": query.writer, "parents": parents })).into_response() } @@ -757,15 +732,6 @@ async fn writer_tree( } } -/// Whom a member reaches, by its links: those neither dormant nor down. -fn reached_by(links: &[Link]) -> BTreeSet<String> { - links - .iter() - .filter(|link| !link.dormant && !link.down) - .map(|link| link.peer.clone()) - .collect() -} - /// `GET /admin/dashboard/state`: the latest snapshot, for a client that wants it whole. async fn current_state(Extension(hub): Extension<Arc<Hub>>) -> Response { hub.want(); |
