Struct ruma_state_res::StateResolution [−][src]
pub struct StateResolution;
Implementations
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_events
- The full recursive set ofauth_events
for each event in thestate_sets
. -
event_map
- TheEventMap
acts as a local cache of state, any event that is not found in theevent_map
will cause an unrecoverableError
inresolve
.
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.
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.
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
event_map
or store
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