From 7c6716358503abee5fab960c45e5fc2de5f61203 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 22:35:10 +0100 Subject: 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). --- src/api/dashboard/mod.rs | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) (limited to 'src/api') 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>, Query(query): Query, ) -> Response { let state = &hub.state; - let mut reports: BTreeMap> = 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> = 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 { - 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>) -> Response { hub.want(); -- cgit v1.3.1