diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-21 14:58:47 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-21 14:58:47 +0100 |
commit | c2633907c530d018254c0cca8d7ce8336c380fc2 (patch) | |
tree | c55895df895f013398702154ed85940e19ab2d0e /synapse/storage/event_federation.py | |
parent | Fix _get_backfill_events to return events in the correct order (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/join_perf (diff) | |
download | synapse-c2633907c530d018254c0cca8d7ce8336c380fc2.tar.xz |
Merge branch 'erikj/join_perf' of github.com:matrix-org/synapse into erikj/backfill_fixes
Diffstat (limited to 'synapse/storage/event_federation.py')
-rw-r--r-- | synapse/storage/event_federation.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py index 34948c30cf..80eff8e6f2 100644 --- a/synapse/storage/event_federation.py +++ b/synapse/storage/event_federation.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from twisted.internet import defer + from ._base import SQLBaseStore, cached from syutil.base64util import encode_base64 @@ -34,16 +36,7 @@ class EventFederationStore(SQLBaseStore): """ def get_auth_chain(self, event_ids): - return self.runInteraction( - "get_auth_chain", - self._get_auth_chain_txn, - event_ids - ) - - def _get_auth_chain_txn(self, txn, event_ids): - results = self._get_auth_chain_ids_txn(txn, event_ids) - - return self._get_events_txn(txn, results) + return self.get_auth_chain_ids(event_ids).addCallback(self._get_events) def get_auth_chain_ids(self, event_ids): return self.runInteraction( @@ -371,7 +364,7 @@ class EventFederationStore(SQLBaseStore): return self.runInteraction( "get_backfill_events", self._get_backfill_events, room_id, event_list, limit - ) + ).addCallback(self._get_events) def _get_backfill_events(self, txn, room_id, event_list, limit): logger.debug( @@ -417,16 +410,26 @@ class EventFederationStore(SQLBaseStore): for row in txn.fetchall(): queue.put(row) - return self._get_events_txn(txn, event_results) + return event_results + @defer.inlineCallbacks def get_missing_events(self, room_id, earliest_events, latest_events, limit, min_depth): - return self.runInteraction( + ids = yield self.runInteraction( "get_missing_events", self._get_missing_events, room_id, earliest_events, latest_events, limit, min_depth ) + events = yield self._get_events(ids) + + events = sorted( + [ev for ev in events if ev.depth >= min_depth], + key=lambda e: e.depth, + ) + + defer.returnValue(events[:limit]) + def _get_missing_events(self, txn, room_id, earliest_events, latest_events, limit, min_depth): @@ -458,14 +461,7 @@ class EventFederationStore(SQLBaseStore): front = new_front event_results |= new_front - events = self._get_events_txn(txn, event_results) - - events = sorted( - [ev for ev in events if ev.depth >= min_depth], - key=lambda e: e.depth, - ) - - return events[:limit] + return event_results def clean_room_for_join(self, room_id): return self.runInteraction( |