refactor state accessor, state cache, user, uiaa

This commit is contained in:
Timo Kösters 2022-08-14 13:38:21 +02:00 committed by Nyaaori
parent 3e22bbeecd
commit 82e7f57b38
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
12 changed files with 116 additions and 933 deletions

View file

@ -1,7 +1,5 @@
/// Builds a StateMap by iterating over all keys that start
/// with state_hash, this gives the full state for the given state_hash.
#[tracing::instrument(skip(self))]
pub async fn state_full_ids(&self, shortstatehash: u64) -> Result<BTreeMap<u64, Arc<EventId>>> {
impl service::room::state_accessor::Data for KeyValueDatabase {
async fn state_full_ids(&self, shortstatehash: u64) -> Result<BTreeMap<u64, Arc<EventId>>> {
let full_state = self
.load_shortstatehash_info(shortstatehash)?
.pop()
@ -21,8 +19,7 @@
Ok(result)
}
#[tracing::instrument(skip(self))]
pub async fn state_full(
async fn state_full(
&self,
shortstatehash: u64,
) -> Result<HashMap<(StateEventType, String), Arc<PduEvent>>> {
@ -59,8 +56,7 @@
}
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
#[tracing::instrument(skip(self))]
pub fn state_get_id(
fn state_get_id(
&self,
shortstatehash: u64,
event_type: &StateEventType,
@ -86,8 +82,7 @@
}
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
#[tracing::instrument(skip(self))]
pub fn state_get(
fn state_get(
&self,
shortstatehash: u64,
event_type: &StateEventType,
@ -98,7 +93,7 @@
}
/// Returns the state hash for this pdu.
pub fn pdu_shortstatehash(&self, event_id: &EventId) -> Result<Option<u64>> {
fn pdu_shortstatehash(&self, event_id: &EventId) -> Result<Option<u64>> {
self.eventid_shorteventid
.get(event_id.as_bytes())?
.map_or(Ok(None), |shorteventid| {
@ -116,8 +111,7 @@
}
/// Returns the full room state.
#[tracing::instrument(skip(self))]
pub async fn room_state_full(
async fn room_state_full(
&self,
room_id: &RoomId,
) -> Result<HashMap<(StateEventType, String), Arc<PduEvent>>> {
@ -129,8 +123,7 @@
}
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
#[tracing::instrument(skip(self))]
pub fn room_state_get_id(
fn room_state_get_id(
&self,
room_id: &RoomId,
event_type: &StateEventType,
@ -144,8 +137,7 @@
}
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
#[tracing::instrument(skip(self))]
pub fn room_state_get(
fn room_state_get(
&self,
room_id: &RoomId,
event_type: &StateEventType,
@ -157,4 +149,3 @@
Ok(None)
}
}