1717from collections import namedtuple
1818from typing import Dict , Iterable , List , Set , Tuple
1919
20- from twisted .internet import defer
21-
2220from synapse .api .constants import EventTypes
2321from synapse .storage ._base import SQLBaseStore
2422from synapse .storage .database import DatabasePool
@@ -103,7 +101,7 @@ def get_max_state_group_txn(txn: Cursor):
103101 )
104102
105103 @cached (max_entries = 10000 , iterable = True )
106- def get_state_group_delta (self , state_group ):
104+ async def get_state_group_delta (self , state_group ):
107105 """Given a state group try to return a previous group and a delta between
108106 the old and the new.
109107
@@ -135,7 +133,7 @@ def _get_state_group_delta_txn(txn):
135133 {(row ["type" ], row ["state_key" ]): row ["event_id" ] for row in delta_ids },
136134 )
137135
138- return self .db_pool .runInteraction (
136+ return await self .db_pool .runInteraction (
139137 "get_state_group_delta" , _get_state_group_delta_txn
140138 )
141139
@@ -367,9 +365,9 @@ def _insert_into_cache(
367365 fetched_keys = non_member_types ,
368366 )
369367
370- def store_state_group (
368+ async def store_state_group (
371369 self , event_id , room_id , prev_group , delta_ids , current_state_ids
372- ):
370+ ) -> int :
373371 """Store a new set of state, returning a newly assigned state group.
374372
375373 Args:
@@ -383,7 +381,7 @@ def store_state_group(
383381 to event_id.
384382
385383 Returns:
386- Deferred[int]: The state group ID
384+ The state group ID
387385 """
388386
389387 def _store_state_group_txn (txn ):
@@ -484,11 +482,13 @@ def _store_state_group_txn(txn):
484482
485483 return state_group
486484
487- return self .db_pool .runInteraction ("store_state_group" , _store_state_group_txn )
485+ return await self .db_pool .runInteraction (
486+ "store_state_group" , _store_state_group_txn
487+ )
488488
489- def purge_unreferenced_state_groups (
489+ async def purge_unreferenced_state_groups (
490490 self , room_id : str , state_groups_to_delete
491- ) -> defer . Deferred :
491+ ) -> None :
492492 """Deletes no longer referenced state groups and de-deltas any state
493493 groups that reference them.
494494
@@ -499,7 +499,7 @@ def purge_unreferenced_state_groups(
499499 to delete.
500500 """
501501
502- return self .db_pool .runInteraction (
502+ await self .db_pool .runInteraction (
503503 "purge_unreferenced_state_groups" ,
504504 self ._purge_unreferenced_state_groups ,
505505 room_id ,
@@ -594,15 +594,15 @@ async def get_previous_state_groups(
594594
595595 return {row ["state_group" ]: row ["prev_state_group" ] for row in rows }
596596
597- def purge_room_state (self , room_id , state_groups_to_delete ):
597+ async def purge_room_state (self , room_id , state_groups_to_delete ):
598598 """Deletes all record of a room from state tables
599599
600600 Args:
601601 room_id (str):
602602 state_groups_to_delete (list[int]): State groups to delete
603603 """
604604
605- return self .db_pool .runInteraction (
605+ await self .db_pool .runInteraction (
606606 "purge_room_state" ,
607607 self ._purge_room_state_txn ,
608608 room_id ,
0 commit comments