@@ -449,8 +449,7 @@ async def resolve_events(
449449 state_map = {ev .event_id : ev for st in state_sets for ev in st }
450450
451451 with Measure (self .clock , "state._resolve_events" ):
452- new_state = await resolve_events_with_store (
453- self .clock ,
452+ new_state = await self ._state_resolution_handler .resolve_events_with_store (
454453 event .room_id ,
455454 room_version ,
456455 state_set_ids ,
@@ -531,8 +530,7 @@ async def resolve_state_groups(
531530 state_groups_histogram .observe (len (state_groups_ids ))
532531
533532 with Measure (self .clock , "state._resolve_events" ):
534- new_state = await resolve_events_with_store (
535- self .clock ,
533+ new_state = await self .resolve_events_with_store (
536534 room_id ,
537535 room_version ,
538536 list (state_groups_ids .values ()),
@@ -552,6 +550,51 @@ async def resolve_state_groups(
552550
553551 return cache
554552
553+ def resolve_events_with_store (
554+ self ,
555+ room_id : str ,
556+ room_version : str ,
557+ state_sets : Sequence [StateMap [str ]],
558+ event_map : Optional [Dict [str , EventBase ]],
559+ state_res_store : "StateResolutionStore" ,
560+ ) -> Awaitable [StateMap [str ]]:
561+ """
562+ Args:
563+ room_id: the room we are working in
564+
565+ room_version: Version of the room
566+
567+ state_sets: List of dicts of (type, state_key) -> event_id,
568+ which are the different state groups to resolve.
569+
570+ event_map:
571+ a dict from event_id to event, for any events that we happen to
572+ have in flight (eg, those currently being persisted). This will be
573+ used as a starting point fof finding the state we need; any missing
574+ events will be requested via state_map_factory.
575+
576+ If None, all events will be fetched via state_res_store.
577+
578+ state_res_store: a place to fetch events from
579+
580+ Returns:
581+ a map from (type, state_key) to event_id.
582+ """
583+ v = KNOWN_ROOM_VERSIONS [room_version ]
584+ if v .state_res == StateResolutionVersions .V1 :
585+ return v1 .resolve_events_with_store (
586+ room_id , state_sets , event_map , state_res_store .get_events
587+ )
588+ else :
589+ return v2 .resolve_events_with_store (
590+ self .clock ,
591+ room_id ,
592+ room_version ,
593+ state_sets ,
594+ event_map ,
595+ state_res_store ,
596+ )
597+
555598
556599def _make_state_cache_entry (
557600 new_state : StateMap [str ], state_groups_ids : Dict [int , StateMap [str ]]
@@ -605,47 +648,6 @@ def _make_state_cache_entry(
605648 )
606649
607650
608- def resolve_events_with_store (
609- clock : Clock ,
610- room_id : str ,
611- room_version : str ,
612- state_sets : Sequence [StateMap [str ]],
613- event_map : Optional [Dict [str , EventBase ]],
614- state_res_store : "StateResolutionStore" ,
615- ) -> Awaitable [StateMap [str ]]:
616- """
617- Args:
618- room_id: the room we are working in
619-
620- room_version: Version of the room
621-
622- state_sets: List of dicts of (type, state_key) -> event_id,
623- which are the different state groups to resolve.
624-
625- event_map:
626- a dict from event_id to event, for any events that we happen to
627- have in flight (eg, those currently being persisted). This will be
628- used as a starting point fof finding the state we need; any missing
629- events will be requested via state_map_factory.
630-
631- If None, all events will be fetched via state_res_store.
632-
633- state_res_store: a place to fetch events from
634-
635- Returns:
636- a map from (type, state_key) to event_id.
637- """
638- v = KNOWN_ROOM_VERSIONS [room_version ]
639- if v .state_res == StateResolutionVersions .V1 :
640- return v1 .resolve_events_with_store (
641- room_id , state_sets , event_map , state_res_store .get_events
642- )
643- else :
644- return v2 .resolve_events_with_store (
645- clock , room_id , room_version , state_sets , event_map , state_res_store
646- )
647-
648-
649651@attr .s (slots = True )
650652class StateResolutionStore :
651653 """Interface that allows state resolution algorithms to access the database
0 commit comments