service(auth_chain): use self
instead of services()
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
97ddb2ce87
commit
82ac6b01b2
1 changed files with 4 additions and 18 deletions
|
@ -63,11 +63,7 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
let chunk_key: Vec<u64> = chunk.iter().map(|(short, _)| short).copied().collect();
|
let chunk_key: Vec<u64> = chunk.iter().map(|(short, _)| short).copied().collect();
|
||||||
if let Some(cached) = services()
|
if let Some(cached) = self.get_cached_eventid_authchain(&chunk_key)? {
|
||||||
.rooms
|
|
||||||
.auth_chain
|
|
||||||
.get_cached_eventid_authchain(&chunk_key)?
|
|
||||||
{
|
|
||||||
trace!("Found cache entry for whole chunk");
|
trace!("Found cache entry for whole chunk");
|
||||||
full_auth_chain.extend(cached.iter().copied());
|
full_auth_chain.extend(cached.iter().copied());
|
||||||
hits = hits.saturating_add(1);
|
hits = hits.saturating_add(1);
|
||||||
|
@ -78,20 +74,13 @@ impl Service {
|
||||||
let mut misses2: usize = 0;
|
let mut misses2: usize = 0;
|
||||||
let mut chunk_cache = Vec::with_capacity(chunk.len());
|
let mut chunk_cache = Vec::with_capacity(chunk.len());
|
||||||
for (sevent_id, event_id) in chunk {
|
for (sevent_id, event_id) in chunk {
|
||||||
if let Some(cached) = services()
|
if let Some(cached) = self.get_cached_eventid_authchain(&[sevent_id])? {
|
||||||
.rooms
|
|
||||||
.auth_chain
|
|
||||||
.get_cached_eventid_authchain(&[sevent_id])?
|
|
||||||
{
|
|
||||||
trace!(?event_id, "Found cache entry for event");
|
trace!(?event_id, "Found cache entry for event");
|
||||||
chunk_cache.extend(cached.iter().copied());
|
chunk_cache.extend(cached.iter().copied());
|
||||||
hits2 = hits2.saturating_add(1);
|
hits2 = hits2.saturating_add(1);
|
||||||
} else {
|
} else {
|
||||||
let auth_chain = self.get_auth_chain_inner(room_id, event_id)?;
|
let auth_chain = self.get_auth_chain_inner(room_id, event_id)?;
|
||||||
services()
|
self.cache_auth_chain(vec![sevent_id], &auth_chain)?;
|
||||||
.rooms
|
|
||||||
.auth_chain
|
|
||||||
.cache_auth_chain(vec![sevent_id], &auth_chain)?;
|
|
||||||
chunk_cache.extend(auth_chain.iter());
|
chunk_cache.extend(auth_chain.iter());
|
||||||
misses2 = misses2.saturating_add(1);
|
misses2 = misses2.saturating_add(1);
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -106,10 +95,7 @@ impl Service {
|
||||||
|
|
||||||
chunk_cache.sort_unstable();
|
chunk_cache.sort_unstable();
|
||||||
chunk_cache.dedup();
|
chunk_cache.dedup();
|
||||||
services()
|
self.cache_auth_chain_vec(chunk_key, &chunk_cache)?;
|
||||||
.rooms
|
|
||||||
.auth_chain
|
|
||||||
.cache_auth_chain_vec(chunk_key, &chunk_cache)?;
|
|
||||||
full_auth_chain.extend(chunk_cache.iter());
|
full_auth_chain.extend(chunk_cache.iter());
|
||||||
misses = misses.saturating_add(1);
|
misses = misses.saturating_add(1);
|
||||||
debug!(
|
debug!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue