mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
include graphviz of state and auth events
This commit is contained in:
parent
052ab6dddd
commit
3afa1ccf8a
3 changed files with 25 additions and 1 deletions
|
|
@ -26,6 +26,9 @@ struct Value {
|
|||
|
||||
/// The edges in the state events' auth chains
|
||||
edges: BTreeSet<Edge>,
|
||||
|
||||
/// A graphviz representation of the resolved state and auth events
|
||||
graphviz: String,
|
||||
}
|
||||
|
||||
/// An edge in the graph of `auth_events` of the resolved state
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use petgraph::dot::Dot;
|
||||
use ruma::{OwnedRoomId, RoomId};
|
||||
use tracing as t;
|
||||
|
||||
|
|
@ -132,9 +133,12 @@ async fn get_room_value(
|
|||
})
|
||||
.collect();
|
||||
|
||||
let graphviz = Dot::new(&graph).to_string();
|
||||
|
||||
Some(Value {
|
||||
resolved_state,
|
||||
pdus,
|
||||
edges,
|
||||
graphviz,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
|
||||
error::Error,
|
||||
fmt,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
|
|
@ -10,6 +11,7 @@ use std::{
|
|||
};
|
||||
|
||||
use petgraph::{
|
||||
dot::Dot,
|
||||
graph::NodeIndex,
|
||||
visit::{depth_first_search, DfsEvent, Reversed},
|
||||
Direction,
|
||||
|
|
@ -29,6 +31,12 @@ use crate::{database::KeyValueDatabase, utils, PduEvent};
|
|||
/// A weightless unit type to use for graphs with unweighted edges
|
||||
pub(crate) struct WeightlessEdge;
|
||||
|
||||
impl fmt::Display for WeightlessEdge {
|
||||
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A directed graph with unweighted edges
|
||||
pub(crate) type DiGraph<T> = petgraph::graph::DiGraph<T, WeightlessEdge>;
|
||||
|
||||
|
|
@ -40,7 +48,7 @@ struct ExtractRoomVersion {
|
|||
}
|
||||
|
||||
/// Information about a state event node for state resolution
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct StateResolutionNode {
|
||||
/// This event's ID
|
||||
pub(crate) event_id: Arc<EventId>,
|
||||
|
|
@ -52,6 +60,12 @@ pub(crate) struct StateResolutionNode {
|
|||
pub(crate) state_key: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for StateResolutionNode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{self:#?}")
|
||||
}
|
||||
}
|
||||
|
||||
/// Information about a state event's edges for state resolution
|
||||
pub(crate) struct StateResolutionEdges {
|
||||
/// This event's ID
|
||||
|
|
@ -306,10 +320,13 @@ fn resolve_room_state(
|
|||
})
|
||||
.collect();
|
||||
|
||||
let graphviz = Dot::new(&graph).to_string();
|
||||
|
||||
Some(Value {
|
||||
resolved_state,
|
||||
pdus,
|
||||
edges,
|
||||
graphviz,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue