Rename resolve_events_with_factory

This commit is contained in:
Erik Johnston 2018-10-24 09:44:22 +01:00
parent 4a28d3d36f
commit 810715f79a
5 changed files with 13 additions and 13 deletions

View File

@ -53,7 +53,7 @@ from synapse.replication.http.federation import (
ReplicationFederationSendEventsRestServlet, ReplicationFederationSendEventsRestServlet,
) )
from synapse.replication.http.membership import ReplicationUserJoinedLeftRoomRestServlet from synapse.replication.http.membership import ReplicationUserJoinedLeftRoomRestServlet
from synapse.state import StateResolutionStore, resolve_events_with_factory from synapse.state import StateResolutionStore, resolve_events_with_store
from synapse.types import UserID, get_domain_from_id from synapse.types import UserID, get_domain_from_id
from synapse.util import logcontext, unwrapFirstError from synapse.util import logcontext, unwrapFirstError
from synapse.util.async_helpers import Linearizer from synapse.util.async_helpers import Linearizer
@ -385,7 +385,7 @@ class FederationHandler(BaseHandler):
event_map[x.event_id] = x event_map[x.event_id] = x
room_version = yield self.store.get_room_version(room_id) room_version = yield self.store.get_room_version(room_id)
state_map = yield resolve_events_with_factory( state_map = yield resolve_events_with_store(
room_version, state_maps, event_map, room_version, state_maps, event_map,
state_res_store=StateResolutionStore(self.store), state_res_store=StateResolutionStore(self.store),
) )

View File

@ -394,7 +394,7 @@ class StateHandler(object):
} }
with Measure(self.clock, "state._resolve_events"): with Measure(self.clock, "state._resolve_events"):
new_state = yield resolve_events_with_factory( new_state = yield resolve_events_with_store(
room_version, state_set_ids, room_version, state_set_ids,
event_map=state_map, event_map=state_map,
state_res_store=StateResolutionStore(self.store), state_res_store=StateResolutionStore(self.store),
@ -478,10 +478,10 @@ class StateResolutionHandler(object):
# start by assuming we won't have any conflicted state, and build up the new # start by assuming we won't have any conflicted state, and build up the new
# state map by iterating through the state groups. If we discover a conflict, # state map by iterating through the state groups. If we discover a conflict,
# we give up and instead use `resolve_events_with_factory`. # we give up and instead use `resolve_events_with_store`.
# #
# XXX: is this actually worthwhile, or should we just let # XXX: is this actually worthwhile, or should we just let
# resolve_events_with_factory do it? # resolve_events_with_store do it?
new_state = {} new_state = {}
conflicted_state = False conflicted_state = False
for st in itervalues(state_groups_ids): for st in itervalues(state_groups_ids):
@ -496,7 +496,7 @@ class StateResolutionHandler(object):
if conflicted_state: if conflicted_state:
logger.info("Resolving conflicted state for %r", room_id) logger.info("Resolving conflicted state for %r", room_id)
with Measure(self.clock, "state._resolve_events"): with Measure(self.clock, "state._resolve_events"):
new_state = yield resolve_events_with_factory( new_state = yield resolve_events_with_store(
room_version, room_version,
list(itervalues(state_groups_ids)), list(itervalues(state_groups_ids)),
event_map=event_map, event_map=event_map,
@ -581,7 +581,7 @@ def _make_state_cache_entry(
) )
def resolve_events_with_factory(room_version, state_sets, event_map, state_res_store): def resolve_events_with_store(room_version, state_sets, event_map, state_res_store):
""" """
Args: Args:
room_version(str): Version of the room room_version(str): Version of the room
@ -604,11 +604,11 @@ def resolve_events_with_factory(room_version, state_sets, event_map, state_res_s
a map from (type, state_key) to event_id. a map from (type, state_key) to event_id.
""" """
if room_version == RoomVersions.V1: if room_version == RoomVersions.V1:
return v1.resolve_events_with_factory( return v1.resolve_events_with_store(
state_sets, event_map, state_res_store.get_events, state_sets, event_map, state_res_store.get_events,
) )
elif room_version == RoomVersions.VDH_TEST: elif room_version == RoomVersions.VDH_TEST:
return v2.resolve_events_with_factory( return v2.resolve_events_with_store(
state_sets, event_map, state_res_store, state_sets, event_map, state_res_store,
) )
else: else:

View File

@ -31,7 +31,7 @@ POWER_KEY = (EventTypes.PowerLevels, "")
@defer.inlineCallbacks @defer.inlineCallbacks
def resolve_events_with_factory(state_sets, event_map, state_map_factory): def resolve_events_with_store(state_sets, event_map, state_map_factory):
""" """
Args: Args:
state_sets(list): List of dicts of (type, state_key) -> event_id, state_sets(list): List of dicts of (type, state_key) -> event_id,

View File

@ -29,7 +29,7 @@ logger = logging.getLogger(__name__)
@defer.inlineCallbacks @defer.inlineCallbacks
def resolve_events_with_factory(state_sets, event_map, state_res_store): def resolve_events_with_store(state_sets, event_map, state_res_store):
"""Resolves the state using the v2 state resolution algorithm """Resolves the state using the v2 state resolution algorithm
Args: Args:

View File

@ -24,7 +24,7 @@ from synapse.event_auth import auth_types_for_event
from synapse.events import FrozenEvent from synapse.events import FrozenEvent
from synapse.state.v2 import ( from synapse.state.v2 import (
lexicographical_topological_sort, lexicographical_topological_sort,
resolve_events_with_factory, resolve_events_with_store,
) )
from synapse.types import EventID from synapse.types import EventID
@ -541,7 +541,7 @@ class StateTestCase(unittest.TestCase):
elif len(prev_events) == 1: elif len(prev_events) == 1:
state_before = dict(state_at_event[prev_events[0]]) state_before = dict(state_at_event[prev_events[0]])
else: else:
state_d = resolve_events_with_factory( state_d = resolve_events_with_store(
[state_at_event[n] for n in prev_events], [state_at_event[n] for n in prev_events],
event_map=event_map, event_map=event_map,
state_res_store=TestStateResolutionStore(event_map), state_res_store=TestStateResolutionStore(event_map),