mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 15:33:50 +01:00
Update some docstrings and comments
This commit is contained in:
parent
772d414975
commit
f8407975e7
1 changed files with 31 additions and 8 deletions
|
@ -2040,8 +2040,10 @@ class FederationHandler(BaseHandler):
|
||||||
auth_events (dict[(str, str)->synapse.events.EventBase]):
|
auth_events (dict[(str, str)->synapse.events.EventBase]):
|
||||||
Map from (event_type, state_key) to event
|
Map from (event_type, state_key) to event
|
||||||
|
|
||||||
What we expect the event's auth_events to be, based on the event's
|
Normally, our calculated auth_events based on the state of the room
|
||||||
position in the dag. I think? maybe??
|
at the event's position in the DAG, though occasionally (eg if the
|
||||||
|
event is an outlier), may be the auth events claimed by the remote
|
||||||
|
server.
|
||||||
|
|
||||||
Also NB that this function adds entries to it.
|
Also NB that this function adds entries to it.
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -2091,25 +2093,35 @@ class FederationHandler(BaseHandler):
|
||||||
origin (str):
|
origin (str):
|
||||||
event (synapse.events.EventBase):
|
event (synapse.events.EventBase):
|
||||||
context (synapse.events.snapshot.EventContext):
|
context (synapse.events.snapshot.EventContext):
|
||||||
|
|
||||||
auth_events (dict[(str, str)->synapse.events.EventBase]):
|
auth_events (dict[(str, str)->synapse.events.EventBase]):
|
||||||
|
Map from (event_type, state_key) to event
|
||||||
|
|
||||||
|
Normally, our calculated auth_events based on the state of the room
|
||||||
|
at the event's position in the DAG, though occasionally (eg if the
|
||||||
|
event is an outlier), may be the auth events claimed by the remote
|
||||||
|
server.
|
||||||
|
|
||||||
|
Also NB that this function adds entries to it.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
defer.Deferred[EventContext]: updated context
|
defer.Deferred[EventContext]: updated context
|
||||||
"""
|
"""
|
||||||
event_auth_events = set(event.auth_event_ids())
|
event_auth_events = set(event.auth_event_ids())
|
||||||
|
|
||||||
# if the event's auth_events refers to events which are not in our
|
# missing_auth is the set of the event's auth_events which we don't yet have
|
||||||
# calculated auth_events, we need to fetch those events from somewhere.
|
# in auth_events.
|
||||||
#
|
|
||||||
# we start by fetching them from the store, and then try calling /event_auth/.
|
|
||||||
missing_auth = event_auth_events.difference(
|
missing_auth = event_auth_events.difference(
|
||||||
e.event_id for e in auth_events.values()
|
e.event_id for e in auth_events.values()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# if we have missing events, we need to fetch those events from somewhere.
|
||||||
|
#
|
||||||
|
# we start by checking if they are in the store, and then try calling /event_auth/.
|
||||||
if missing_auth:
|
if missing_auth:
|
||||||
# TODO: can we use store.have_seen_events here instead?
|
# TODO: can we use store.have_seen_events here instead?
|
||||||
have_events = yield self.store.get_seen_events_with_rejections(missing_auth)
|
have_events = yield self.store.get_seen_events_with_rejections(missing_auth)
|
||||||
logger.debug("Got events %s from store", have_events)
|
logger.debug("Found events %s in the store", have_events)
|
||||||
missing_auth.difference_update(have_events.keys())
|
missing_auth.difference_update(have_events.keys())
|
||||||
else:
|
else:
|
||||||
have_events = {}
|
have_events = {}
|
||||||
|
@ -2164,15 +2176,23 @@ class FederationHandler(BaseHandler):
|
||||||
event.auth_event_ids()
|
event.auth_event_ids()
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
# FIXME:
|
|
||||||
logger.exception("Failed to get auth chain")
|
logger.exception("Failed to get auth chain")
|
||||||
|
|
||||||
if event.internal_metadata.is_outlier():
|
if event.internal_metadata.is_outlier():
|
||||||
|
# XXX: given that, for an outlier, we'll be working with the
|
||||||
|
# event's *claimed* auth events rather than those we calculated:
|
||||||
|
# (a) is there any point in this test, since different_auth below will
|
||||||
|
# obviously be empty
|
||||||
|
# (b) alternatively, why don't we do it earlier?
|
||||||
logger.info("Skipping auth_event fetch for outlier")
|
logger.info("Skipping auth_event fetch for outlier")
|
||||||
return context
|
return context
|
||||||
|
|
||||||
# FIXME: Assumes we have and stored all the state for all the
|
# FIXME: Assumes we have and stored all the state for all the
|
||||||
# prev_events
|
# prev_events
|
||||||
|
#
|
||||||
|
# FIXME: what does the fixme above mean? where do prev_events come into
|
||||||
|
# it, why do we care about the state for those events, and what does "have and
|
||||||
|
# stored" mean? Seems erik wrote it in c1d860870b
|
||||||
different_auth = event_auth_events.difference(
|
different_auth = event_auth_events.difference(
|
||||||
e.event_id for e in auth_events.values()
|
e.event_id for e in auth_events.values()
|
||||||
)
|
)
|
||||||
|
@ -2186,6 +2206,9 @@ class FederationHandler(BaseHandler):
|
||||||
different_auth,
|
different_auth,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# now we state-resolve between our own idea of the auth events, and the remote's
|
||||||
|
# idea of them.
|
||||||
|
|
||||||
room_version = yield self.store.get_room_version(event.room_id)
|
room_version = yield self.store.get_room_version(event.room_id)
|
||||||
|
|
||||||
different_events = yield make_deferred_yieldable(
|
different_events = yield make_deferred_yieldable(
|
||||||
|
|
Loading…
Reference in a new issue