optimize auth_chain short_id to event_id translation step
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
ab06701ed0
commit
36677bb982
3 changed files with 46 additions and 17 deletions
|
@ -141,6 +141,23 @@ pub async fn get_eventid_from_short(&self, shorteventid: u64) -> Result<Arc<Even
|
|||
.map_err(|e| err!(Database("Failed to find EventId from short {shorteventid:?}: {e:?}")))
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn multi_get_eventid_from_short(&self, shorteventid: &[u64]) -> Vec<Result<Arc<EventId>>> {
|
||||
const BUFSIZE: usize = size_of::<u64>();
|
||||
|
||||
let keys: Vec<[u8; BUFSIZE]> = shorteventid
|
||||
.iter()
|
||||
.map(|short| short.to_be_bytes())
|
||||
.collect();
|
||||
|
||||
self.db
|
||||
.shorteventid_eventid
|
||||
.get_batch_blocking(keys.iter())
|
||||
.into_iter()
|
||||
.map(Deserialized::deserialized)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
pub async fn get_statekey_from_short(&self, shortstatekey: u64) -> Result<(StateEventType, String)> {
|
||||
const BUFSIZE: usize = size_of::<u64>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue