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. Each StateMap represents a possible fork in the state of a room.

  • auth_events - The full recursive set of auth_events for each event in the state_sets.

  • event_map - The EventMap acts as a local cache of state, any event that is not found in the event_map will cause an unrecoverable Error in resolve.

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 EventIds 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 EventIds 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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.