Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
1848f082
Commit
1848f082
authored
4 years ago
by
Devin Ragotzy
Browse files
Options
Downloads
Patches
Plain Diff
Use full sorting algorithm on incoming PDU's in membership
parent
3c26166f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/client_server/membership.rs
+44
-6
44 additions, 6 deletions
src/client_server/membership.rs
with
44 additions
and
6 deletions
src/client_server/membership.rs
+
44
−
6
View file @
1848f082
...
...
@@ -497,7 +497,7 @@ async fn join_room_by_id_helper(
.collect
::
<
Result
<
BTreeMap
<
EventId
,
StateEvent
>
,
_
>>
()
.map_err
(|
_
|
Error
::
bad_database
(
"Invalid PDU found in db."
))
?
;
let
_
auth_chain
=
send_join_response
let
auth_chain
=
send_join_response
.room_state
.auth_chain
.iter
()
...
...
@@ -505,16 +505,54 @@ async fn join_room_by_id_helper(
.map
(
StateEvent
::
Full
)
.collect
::
<
Vec
<
_
>>
();
// TODO make StateResolution's methods free functions ? or no self param ?
let
sorted_events_ids
=
state_res
::
StateResolution
::
reverse_topological_power_sort
(
let
power_events
=
event_map
.values
()
.filter
(|
pdu
|
pdu
.is_power_event
())
.map
(|
pdu
|
pdu
.event_id
())
.collect
::
<
Vec
<
_
>>
();
// TODO these events are not guaranteed to be sorted but they are resolved, do
// we need the auth_chain
let
sorted_power_events
=
state_res
::
StateResolution
::
reverse_topological_power_sort
(
&
room_id
,
&
event_map
.keys
()
.cloned
()
.collect
::
<
Vec
<
_
>>
(),
&
power_events
,
&
mut
event_map
,
&
db
.rooms
,
&
auth_chain
// if we only use it here just build this list in the first place
.iter
()
.map
(|
pdu
|
pdu
.event_id
())
.collect
::
<
Vec
<
_
>>
(),
);
// TODO we may be able to skip this since they are resolved according to spec
let
resolved_power
=
state_res
::
StateResolution
::
iterative_auth_check
(
room_id
,
&
RoomVersionId
::
Version6
,
&
sorted_power_events
,
&
BTreeMap
::
new
(),
// unconflicted events
&
mut
event_map
,
&
db
.rooms
,
)
.expect
(
"iterative auth check failed on resolved events"
);
// TODO do we need to dedup them
let
events_to_sort
=
event_map
.keys
()
.filter
(|
id
|
!
sorted_power_events
.contains
(
id
))
.cloned
()
.collect
::
<
Vec
<
_
>>
();
let
power_level
=
resolved_power
.get
(
&
(
EventType
::
RoomPowerLevels
,
Some
(
""
.into
())));
let
sorted_event_ids
=
state_res
::
StateResolution
::
mainline_sort
(
room_id
,
&
events_to_sort
,
power_level
,
&
mut
event_map
,
&
db
.rooms
,
&
[],
// TODO auth_diff: is this none since we have a set of resolved events we only want to sort
);
for
ev_id
in
&
sorted_event
s
_ids
{
for
ev_id
in
&
sorted_event_ids
{
// this is a `state_res::StateEvent` that holds a `ruma::Pdu`
let
pdu
=
event_map
.get
(
ev_id
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment