diff options
author | Erik Johnston <erikj@jki.re> | 2016-09-02 14:16:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 14:16:28 +0100 |
commit | 1ffe9578d1be3d267a8c0e4d678b9ef434cfc07f (patch) | |
tree | a487d2e6c09be1db6bd12981935c9a19ead64dbe /synapse | |
parent | Bump max_entries on get_destination_retry_timings (diff) | |
parent | Only pull out IDs from DB for /state_ids/ request (diff) | |
download | synapse-1ffe9578d1be3d267a8c0e4d678b9ef434cfc07f.tar.xz |
Merge pull request #1063 from matrix-org/erikj/pull_out_ids_only
Only pull out IDs from DB for /state_ids/ request
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/federation/federation_server.py | 10 | ||||
-rw-r--r-- | synapse/handlers/federation.py | 26 |
2 files changed, 30 insertions, 6 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index aba19639c7..5621655098 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -223,16 +223,14 @@ class FederationServer(FederationBase): if not in_room: raise AuthError(403, "Host not in room.") - pdus = yield self.handler.get_state_for_pdu( + state_ids = yield self.handler.get_state_ids_for_pdu( room_id, event_id, ) - auth_chain = yield self.store.get_auth_chain( - [pdu.event_id for pdu in pdus] - ) + auth_chain_ids = yield self.store.get_auth_chain_ids(state_ids) defer.returnValue((200, { - "pdu_ids": [pdu.event_id for pdu in pdus], - "auth_chain_ids": [pdu.event_id for pdu in auth_chain], + "pdu_ids": state_ids, + "auth_chain_ids": auth_chain_ids, })) @defer.inlineCallbacks diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 8e61d74b13..fda09b21c0 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -1103,6 +1103,32 @@ class FederationHandler(BaseHandler): defer.returnValue([]) @defer.inlineCallbacks + def get_state_ids_for_pdu(self, room_id, event_id): + yield run_on_reactor() + + state_groups = yield self.store.get_state_groups_ids( + room_id, [event_id] + ) + + if state_groups: + _, state = state_groups.items().pop() + results = state + + event = yield self.store.get_event(event_id) + if event and event.is_state(): + # Get previous state + if "replaces_state" in event.unsigned: + prev_id = event.unsigned["replaces_state"] + if prev_id != event.event_id: + results[(event.type, event.state_key)] = prev_id + else: + del results[(event.type, event.state_key)] + + defer.returnValue(results.values()) + else: + defer.returnValue([]) + + @defer.inlineCallbacks @log_function def on_backfill_request(self, origin, room_id, pdu_list, limit): in_room = yield self.auth.check_host_in_room(room_id, origin) |