Merge pull request #179 from matrix-org/erikj/state_group_outliers
Don't compute EventContext for outliers.
This commit is contained in:
commit
9dda396baa
|
@ -900,8 +900,10 @@ class FederationHandler(BaseHandler):
|
|||
event.event_id, event.signatures,
|
||||
)
|
||||
|
||||
outlier = event.internal_metadata.is_outlier()
|
||||
|
||||
context = yield self.state_handler.compute_event_context(
|
||||
event, old_state=state
|
||||
event, old_state=state, outlier=outlier,
|
||||
)
|
||||
|
||||
if not auth_events:
|
||||
|
@ -912,7 +914,7 @@ class FederationHandler(BaseHandler):
|
|||
event.event_id, auth_events,
|
||||
)
|
||||
|
||||
is_new_state = not event.internal_metadata.is_outlier()
|
||||
is_new_state = not outlier
|
||||
|
||||
# This is a hack to fix some old rooms where the initial join event
|
||||
# didn't reference the create event in its auth events.
|
||||
|
|
|
@ -106,7 +106,7 @@ class StateHandler(object):
|
|||
defer.returnValue(state)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def compute_event_context(self, event, old_state=None):
|
||||
def compute_event_context(self, event, old_state=None, outlier=False):
|
||||
""" Fills out the context with the `current state` of the graph. The
|
||||
`current state` here is defined to be the state of the event graph
|
||||
just before the event - i.e. it never includes `event`
|
||||
|
@ -119,9 +119,23 @@ class StateHandler(object):
|
|||
Returns:
|
||||
an EventContext
|
||||
"""
|
||||
yield run_on_reactor()
|
||||
|
||||
context = EventContext()
|
||||
|
||||
yield run_on_reactor()
|
||||
if outlier:
|
||||
# If this is an outlier, then we know it shouldn't have any current
|
||||
# state. Certainly store.get_current_state won't return any, and
|
||||
# persisting the event won't store the state group.
|
||||
if old_state:
|
||||
context.current_state = {
|
||||
(s.type, s.state_key): s for s in old_state
|
||||
}
|
||||
else:
|
||||
context.current_state = {}
|
||||
context.prev_state_events = []
|
||||
context.state_group = None
|
||||
defer.returnValue(context)
|
||||
|
||||
if old_state:
|
||||
context.current_state = {
|
||||
|
|
|
@ -100,7 +100,7 @@ class FederationTestCase(unittest.TestCase):
|
|||
return defer.succeed({})
|
||||
self.datastore.have_events.side_effect = have_events
|
||||
|
||||
def annotate(ev, old_state=None):
|
||||
def annotate(ev, old_state=None, outlier=False):
|
||||
context = Mock()
|
||||
context.current_state = {}
|
||||
context.auth_events = {}
|
||||
|
@ -120,7 +120,7 @@ class FederationTestCase(unittest.TestCase):
|
|||
)
|
||||
|
||||
self.state_handler.compute_event_context.assert_called_once_with(
|
||||
ANY, old_state=None,
|
||||
ANY, old_state=None, outlier=False
|
||||
)
|
||||
|
||||
self.auth.check.assert_called_once_with(ANY, auth_events={})
|
||||
|
|
Loading…
Reference in New Issue