state-res: Simplify get_auth_chain_diff signature

It never returned Err(_), so the return type shouldn't be Result<_>.
This commit is contained in:
Jonas Platte 2021-09-04 10:37:15 +02:00
parent 290c61820b
commit 324fb58a62
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -79,7 +79,7 @@ where
debug!("{:?}", conflicting); debug!("{:?}", conflicting);
// The set of auth events that are not common across server forks // The set of auth events that are not common across server forks
let mut auth_diff = get_auth_chain_diff(auth_chain_sets)?; let mut auth_diff = get_auth_chain_diff(auth_chain_sets);
// Add the auth_diff to conflicting now we have a full set of conflicting events // Add the auth_diff to conflicting now we have a full set of conflicting events
auth_diff.extend(conflicting.values().cloned().flatten().flatten()); auth_diff.extend(conflicting.values().cloned().flatten().flatten());
@ -195,16 +195,16 @@ pub fn separate(
} }
/// Returns a Vec of deduped EventIds that appear in some chains but not others. /// Returns a Vec of deduped EventIds that appear in some chains but not others.
pub fn get_auth_chain_diff(auth_chain_sets: Vec<HashSet<EventId>>) -> Result<HashSet<EventId>> { pub fn get_auth_chain_diff(auth_chain_sets: Vec<HashSet<EventId>>) -> HashSet<EventId> {
if let Some(first) = auth_chain_sets.first().cloned() { if let Some(first) = auth_chain_sets.first().cloned() {
let common = auth_chain_sets let common = auth_chain_sets
.iter() .iter()
.skip(1) .skip(1)
.fold(first, |a, b| a.intersection(b).cloned().collect::<HashSet<EventId>>()); .fold(first, |a, b| a.intersection(b).cloned().collect::<HashSet<EventId>>());
Ok(auth_chain_sets.into_iter().flatten().filter(|id| !common.contains(id)).collect()) auth_chain_sets.into_iter().flatten().filter(|id| !common.contains(id)).collect()
} else { } else {
Ok(HashSet::new()) HashSet::new()
} }
} }