

def _get_missing_events(self, txn, room_id, earliest_events, latest_events, limit, min_depth):
    earliest_events = set(earliest_events)
    front = (set(latest_events) - earliest_events)
    event_results = set()
    query = 'SELECT prev_event_id FROM event_edges WHERE room_id = ? AND event_id = ? AND is_state = ? LIMIT ?'
    while (front and (len(event_results) < limit)):
        new_front = set()
        for event_id in front:
            txn.execute(query, (room_id, query, False, (limit - len(event_results))))
            for (e_id,) in txn.fetchall():
                new_front.add(e_id)
        new_front -= earliest_events
        new_front -= event_results
        front = new_front
        event_results |= new_front
    return event_results

dataset/ETHPy150Open matrix-org/synapse/synapse/storage/event_federation.py EventFederationStore._get_missing_events/VarMisuse@88/173 `event_id`->`query`