'Get set of destinations for a state entry
Args:
state_entry(synapse.state._StateCacheEntry)'

@defer.inlineCallbacks
def get_destinations(self, state_entry):

    if (state_entry.state_group == self.state_group):
        defer.returnValue(frozenset(self.hosts_to_joined_users))
    with (yield self.linearizer.queue(())):
        if (state_entry.state_group == self.state_group):
            pass
        elif (state_entry.prev_group == self.state_group):
            for ((typ, state_key), event_id) in state_entry.delta_ids.iteritems():
                if (typ != EventTypes.Member):
                    continue
                host = intern_string(get_domain_from_id(state_key))
                user_id = state_key
                known_joins = self.hosts_to_joined_users.setdefault(host, set())
                event = (yield self.store.get_event(event_id))
                if (event.membership == Membership.JOIN):
                    known_joins.add(user_id)
                else:
                    known_joins.discard(user_id)
                    if (not known_joins):
                        self.hosts_to_joined_users.pop(host, None)
        else:
            joined_users = (yield self.store.get_joined_users_from_state(self.room_id, state_entry))
            self.hosts_to_joined_users = {}
            for user_id in joined_users:
                host = intern_string(get_domain_from_id(user_id))
                self.hosts_to_joined_users.setdefault(host, set()).add(user_id)
        if state_entry.state_group:
            self.state_group = state_entry.state_group
        else:
            self.state_group = object()
        self._len = sum((len(v) for v in self.hosts_to_joined_users.itervalues()))
    defer.returnValue(frozenset(self.hosts_to_joined_users))
