Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
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
Maunium
synapse
Commits
d787e41b
Commit
d787e41b
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Measure StateHandler._resolve_events
parent
6cf0ba14
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/state.py
+40
-38
40 additions, 38 deletions
synapse/state.py
with
40 additions
and
38 deletions
synapse/state.py
+
40
−
38
View file @
d787e41b
...
...
@@ -18,6 +18,7 @@ from twisted.internet import defer
from
synapse.util.logutils
import
log_function
from
synapse.util.caches.expiringcache
import
ExpiringCache
from
synapse.util.metrics
import
Measure
from
synapse.api.constants
import
EventTypes
from
synapse.api.errors
import
AuthError
from
synapse.api.auth
import
AuthEventTypes
...
...
@@ -263,48 +264,49 @@ class StateHandler(object):
from (type, state_key) to event. prev_states is a list of event_ids.
:rtype: (dict[(str, str), synapse.events.FrozenEvent], list[str])
"""
state
=
{}
for
st
in
state_sets
:
for
e
in
st
:
state
.
setdefault
(
(
e
.
type
,
e
.
state_key
),
{}
)[
e
.
event_id
]
=
e
unconflicted_state
=
{
k
:
v
.
values
()[
0
]
for
k
,
v
in
state
.
items
()
if
len
(
v
.
values
())
==
1
}
conflicted_state
=
{
k
:
v
.
values
()
for
k
,
v
in
state
.
items
()
if
len
(
v
.
values
())
>
1
}
with
Measure
(
self
.
clock
,
"
state._resolve_events
"
):
state
=
{}
for
st
in
state_sets
:
for
e
in
st
:
state
.
setdefault
(
(
e
.
type
,
e
.
state_key
),
{}
)[
e
.
event_id
]
=
e
unconflicted_state
=
{
k
:
v
.
values
()[
0
]
for
k
,
v
in
state
.
items
()
if
len
(
v
.
values
())
==
1
}
if
event_type
:
prev_states_events
=
conflicted_state
.
get
(
(
event_type
,
state_key
),
[]
)
prev_states
=
[
s
.
event_id
for
s
in
prev_states_events
]
else
:
prev_states
=
[]
conflicted_state
=
{
k
:
v
.
values
()
for
k
,
v
in
state
.
items
()
if
len
(
v
.
values
())
>
1
}
auth_events
=
{
k
:
e
for
k
,
e
in
unconflicted_state
.
items
()
if
k
[
0
]
in
AuthEventTypes
}
if
event_type
:
prev_states_events
=
conflicted_state
.
get
(
(
event_type
,
state_key
),
[]
)
prev_states
=
[
s
.
event_id
for
s
in
prev_states_events
]
else
:
prev_states
=
[]
try
:
resolved_state
=
self
.
_resolve_state_events
(
conflicted_state
,
auth_events
)
except
:
logger
.
exception
(
"
Failed to resolve state
"
)
raise
auth_events
=
{
k
:
e
for
k
,
e
in
unconflicted_state
.
items
()
if
k
[
0
]
in
AuthEventTypes
}
try
:
resolved_state
=
self
.
_resolve_state_events
(
conflicted_state
,
auth_events
)
except
:
logger
.
exception
(
"
Failed to resolve state
"
)
raise
new_state
=
unconflicted_state
new_state
.
update
(
resolved_state
)
new_state
=
unconflicted_state
new_state
.
update
(
resolved_state
)
return
new_state
,
prev_states
...
...
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