2022-06-20 11:31:27 +02:00
|
|
|
pub trait Data {
|
|
|
|
|
fn get_room_shortstatehash(room_id: &RoomId);
|
|
|
|
|
}
|
2020-08-06 08:29:59 -04:00
|
|
|
|
2020-10-27 19:10:09 -04:00
|
|
|
/// Returns the last state hash key added to the db for the given room.
|
2021-02-28 12:41:03 +01:00
|
|
|
#[tracing::instrument(skip(self))]
|
2021-03-17 22:30:25 +01:00
|
|
|
pub fn current_shortstatehash(&self, room_id: &RoomId) -> Result<Option<u64>> {
|
|
|
|
|
self.roomid_shortstatehash
|
|
|
|
|
.get(room_id.as_bytes())?
|
|
|
|
|
.map_or(Ok(None), |bytes| {
|
|
|
|
|
Ok(Some(utils::u64_from_bytes(&bytes).map_err(|_| {
|
|
|
|
|
Error::bad_database("Invalid shortstatehash in roomid_shortstatehash")
|
|
|
|
|
})?))
|
|
|
|
|
})
|
2020-08-06 08:29:59 -04:00
|
|
|
}
|
|
|
|
|
|