Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grapevine
Manage
Activity
Members
Labels
Plan
Issues
72
Issue boards
Milestones
Wiki
Code
Merge requests
17
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Matrix projects
Grapevine
Merge requests
!126
refactor fetch_unknown_prev_events
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
refactor fetch_unknown_prev_events
charles/refactor-fetch-unknown-prev-events
into
main
Overview
1
Commits
1
Pipelines
1
Changes
1
Open
Charles Hall
requested to merge
charles/refactor-fetch-unknown-prev-events
into
main
2 months ago
Overview
1
Commits
1
Pipelines
1
Changes
1
Expand
Early returns (or continues, in this case) good.
👍
0
👎
0
Merge request reports
Compare
main
main (HEAD)
and
latest version
latest version
367a702f
1 commit,
2 months ago
1 file
+
39
−
40
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/service/rooms/event_handler.rs
+
39
−
40
Options
@@ -1442,7 +1442,7 @@ impl Service {
let
mut
amount
=
0
;
while
let
Some
(
prev_event_id
)
=
todo_outlier_stack
.pop
()
{
if
let
Some
((
pdu
,
json_opt
))
=
self
let
Some
((
pdu
,
json_opt
))
=
self
.fetch_and_handle_outliers
(
origin
,
&
[
prev_event_id
.clone
()],
@@ -1452,51 +1452,50 @@ impl Service {
)
.await
.pop
()
{
Self
::
check_room_id
(
room_id
,
&
pdu
)
?
;
else
{
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
continue
;
};
if
amount
>
services
()
.globals
.max_fetch_prev_events
()
{
// Max limit reached
warn!
(
"Max prev event limit reached!"
);
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
continue
;
}
Self
::
check_room_id
(
room_id
,
&
pdu
)
?
;
if
let
Some
(
json
)
=
json_opt
.or_else
(||
{
services
()
.rooms
.outlier
.get_outlier_pdu_json
(
&
prev_event_id
)
.ok
()
.flatten
()
})
{
if
pdu
.origin_server_ts
>
first_pdu_in_room
.origin_server_ts
{
amount
+=
1
;
for
prev_prev
in
&
pdu
.prev_events
{
if
!
graph
.contains_key
(
prev_prev
)
{
todo_outlier_stack
.push
(
prev_prev
.clone
());
}
}
if
amount
>
services
()
.globals
.max_fetch_prev_events
()
{
warn!
(
"Max prev event limit reached"
);
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
continue
;
}
graph
.insert
(
prev_event_id
.clone
(),
pdu
.prev_events
.iter
()
.cloned
()
.collect
(),
);
}
else
{
// Time based check failed
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
}
let
Some
(
json
)
=
json_opt
.or_else
(||
{
services
()
.rooms
.outlier
.get_outlier_pdu_json
(
&
prev_event_id
)
.ok
()
.flatten
()
})
else
{
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
continue
;
};
eventid_info
.insert
(
prev_event_id
.clone
(),
(
pdu
,
json
));
}
else
{
// Get json failed, so this was not fetched over federation
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
}
}
else
{
// Fetch and handle failed
if
pdu
.origin_server_ts
<=
first_pdu_in_room
.origin_server_ts
{
graph
.insert
(
prev_event_id
.clone
(),
HashSet
::
new
());
continue
;
}
amount
+=
1
;
for
prev_prev
in
&
pdu
.prev_events
{
if
!
graph
.contains_key
(
prev_prev
)
{
todo_outlier_stack
.push
(
prev_prev
.clone
());
}
}
graph
.insert
(
prev_event_id
.clone
(),
pdu
.prev_events
.iter
()
.cloned
()
.collect
(),
);
eventid_info
.insert
(
prev_event_id
.clone
(),
(
pdu
,
json
));
}
let
sorted
=
Loading