def _add_event_and_auth_chain_to_graph(graph, room_id, event_id, event_map, state_res_store, auth_diff): """Helper function for _reverse_topological_power_sort that add the event and its auth chain (that is in the auth diff) to the graph Args: graph (dict[str, set[str]]): A map from event ID to the events auth event IDs room_id (str): the room we are working in event_id (str): Event to add to the graph event_map (dict[str,FrozenEvent]) state_res_store (StateResolutionStore) auth_diff (set[str]): Set of event IDs that are in the auth difference. """ state = [event_id] while state: eid = state.pop() graph.setdefault(eid, set()) event = yield _get_event(room_id, eid, event_map, state_res_store) for aid in event.auth_event_ids(): if aid in auth_diff: if aid not in graph: state.append(aid) graph.setdefault(eid, set()).add(aid)
async def _add_event_and_auth_chain_to_graph( graph: Dict[str, Set[str]], room_id: str, event_id: str, event_map: Dict[str, EventBase], state_res_store: "synapse.state.StateResolutionStore", auth_diff: Set[str], ) -> None: """Helper function for _reverse_topological_power_sort that add the event and its auth chain (that is in the auth diff) to the graph Args: graph: A map from event ID to the events auth event IDs room_id: the room we are working in event_id: Event to add to the graph event_map state_res_store auth_diff: Set of event IDs that are in the auth difference. """ state = [event_id] while state: eid = state.pop() graph.setdefault(eid, set()) event = await _get_event(room_id, eid, event_map, state_res_store) for aid in event.auth_event_ids(): if aid in auth_diff: if aid not in graph: state.append(aid) graph.setdefault(eid, set()).add(aid)