Struct ruma::state_res::StateResolution [−][src]
pub struct StateResolution;
state-res
only.Implementations
pub fn resolve<E, F>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[HashMap<(EventType, String), EventId, RandomState>],
auth_chain_sets: Vec<HashSet<EventId, RandomState>, Global>,
fetch_event: F
) -> Result<HashMap<(EventType, String), EventId, RandomState>, Error> where
E: Event,
F: Fn(&EventId) -> Option<Arc<E>>,
pub fn resolve<E, F>(
room_id: &RoomId,
room_version: &RoomVersionId,
state_sets: &[HashMap<(EventType, String), EventId, RandomState>],
auth_chain_sets: Vec<HashSet<EventId, RandomState>, Global>,
fetch_event: F
) -> Result<HashMap<(EventType, String), EventId, RandomState>, Error> where
E: Event,
F: Fn(&EventId) -> Option<Arc<E>>,
Resolve sets of state events as they come in. Internally StateResolution
builds a graph
and an auth chain to allow for state conflict resolution.
Arguments
-
state_sets
- The incoming state to resolve. EachStateMap
represents a possible fork in the state of a room. -
auth_chain_sets
- The full recursive set ofauth_events
for each event in thestate_sets
. -
fetch_event
- Any event not found in theevent_map
will defer to this closure to find the event.
Invariants
The caller of StateResolution::resolve
must ensure that all the events are from the same
room. Although this function takes a RoomId
it does not check that each event is part
of the same room.
Split the events that have no conflicts from those that are conflicting.
The return tuple looks like (unconflicted, conflicted)
.
State is determined to be conflicting if for the given key (EventType, StateKey) there is not exactly one eventId. This includes missing events, if one state_set includes an event that none of the other have this is a conflicting event.
pub fn get_auth_chain_diff(
_room_id: &RoomId,
auth_chain_sets: Vec<HashSet<EventId, RandomState>, Global>
) -> Result<HashSet<EventId, RandomState>, Error>
pub fn get_auth_chain_diff(
_room_id: &RoomId,
auth_chain_sets: Vec<HashSet<EventId, RandomState>, Global>
) -> Result<HashSet<EventId, RandomState>, Error>
Returns a Vec of deduped EventIds that appear in some chains but not others.
Events are sorted from “earliest” to “latest”. They are compared using
the negative power level (reverse topological ordering), the
origin server timestamp and incase of a tie the EventId
s
are compared lexicographically.
The power level is negative because a higher power level is equated to an earlier (further back in time) origin server timestamp.
Sorts the event graph based on number of outgoing/incoming edges, where
key_fn
is used as a tie breaker. The tie breaker happens based on
power level, age, and event_id.
pub fn iterative_auth_check<E, F>(
room_version: &RoomVersion,
events_to_check: &[EventId],
unconflicted_state: &HashMap<(EventType, String), EventId, RandomState>,
fetch_event: F
) -> Result<HashMap<(EventType, String), EventId, RandomState>, Error> where
E: Event,
F: Fn(&EventId) -> Option<Arc<E>>,
pub fn iterative_auth_check<E, F>(
room_version: &RoomVersion,
events_to_check: &[EventId],
unconflicted_state: &HashMap<(EventType, String), EventId, RandomState>,
fetch_event: F
) -> Result<HashMap<(EventType, String), EventId, RandomState>, Error> where
E: Event,
F: Fn(&EventId) -> Option<Arc<E>>,
Check the that each event is authenticated based on the events before it.
Returns
The unconflicted_state
combined with the newly auth’ed events. So any event that
fails the event_auth::auth_check
will be excluded from the returned StateMap<EventId>
.
For each events_to_check
event we gather the events needed to auth it from the
the fetch_event
closure and verify each event using the event_auth::auth_check
function.
Returns the sorted to_sort
list of EventId
s based on a mainline sort using
the depth of resolved_power_level
, the server timestamp, and the eventId.
The depth of the given event is calculated based on the depth of it’s closest “parent” power_level event. If there have been two power events the after the most recent are depth 0, the events before (with the first power level as a parent) will be marked as depth 1. depth 1 is “older” than depth 0.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for StateResolution
impl Send for StateResolution
impl Sync for StateResolution
impl Unpin for StateResolution
impl UnwindSafe for StateResolution
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more