Skip to content

Commit

Permalink
Revert "bugfix for PRID calculation error"
Browse files Browse the repository at this point in the history
This reverts commit 36a2521.
  • Loading branch information
aramikm committed May 1, 2024
1 parent 36a2521 commit 7bff885
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions core/src/graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,6 @@ impl Graph {
})
.collect();

// we skip checking PRIDs for connections that we just added
let prids_skip_list = ids_to_add.clone();
// Now try to add new connections into pages already being updated
// Note: these pages have already been cloned, so we don't clone them again
let mut add_iter = ids_to_add.iter().cloned().peekable();
Expand All @@ -302,7 +300,6 @@ impl Graph {
aggressive,
dsnp_version_config,
&encryption_key,
&prids_skip_list,
);

if let None = add_iter.peek() {
Expand Down Expand Up @@ -338,7 +335,6 @@ impl Graph {
PageFullnessMode::Aggressive,
dsnp_version_config,
&encryption_key,
&prids_skip_list,
);

if page_modified {
Expand All @@ -365,7 +361,6 @@ impl Graph {
PageFullnessMode::Aggressive,
dsnp_version_config,
&encryption_key,
&prids_skip_list,
) {
updated_pages.insert(new_page.page_id(), new_page);
}
Expand All @@ -382,7 +377,6 @@ impl Graph {
fullness_mode: PageFullnessMode,
dsnp_version_config: &DsnpVersionConfig,
encryption_key: &Option<ResolvedKeyPair>,
prid_skip_list: &Vec<DsnpUserId>,
) -> bool {
let mut page_modified = false;
while let Some(id_to_add) = add_iter.peek() {
Expand All @@ -392,7 +386,6 @@ impl Graph {
fullness_mode,
dsnp_version_config,
encryption_key,
prid_skip_list,
) {
page_modified = true;
let _ = add_iter.next(); // TODO: prefer advance_by(1) once that stabilizes
Expand Down Expand Up @@ -658,7 +651,7 @@ impl Graph {
fn apply_prids(
&self,
updated_page: &mut GraphPage,
prid_skip_list: &Vec<DsnpUserId>,
ids_to_add: &Vec<DsnpUserId>,
encryption_key: &ResolvedKeyPair,
) -> DsnpGraphResult<()> {
if self.get_connection_type() != ConnectionType::Friendship(PrivacyType::Private) {
Expand All @@ -672,9 +665,9 @@ impl Graph {
.connections()
.clone()
.iter()
.filter(|c| !prid_skip_list.contains(&c.user_id))
.filter(|c| !ids_to_add.contains(&c.user_id))
{
if // duration_days_since(c.since) > max_allowed_stale_days &&
if duration_days_since(c.since) > max_allowed_stale_days &&
!self
.user_key_manager
.read()
Expand Down Expand Up @@ -711,7 +704,6 @@ impl Graph {
mode: PageFullnessMode,
dsnp_version_config: &DsnpVersionConfig,
encryption_key: &Option<ResolvedKeyPair>,
prid_skip_list: &Vec<DsnpUserId>,
) -> DsnpGraphResult<()> {
let connection_type = self.get_connection_type();
let max_connections_per_page =
Expand Down Expand Up @@ -745,7 +737,7 @@ impl Graph {
ConnectionType::Friendship(PrivacyType::Private) => {
let encryption_key =
encryption_key.as_ref().ok_or(DsnpGraphError::NoResolvedActiveKeyFound)?;
self.apply_prids(&mut temp_page, prid_skip_list, &encryption_key)
self.apply_prids(&mut temp_page, &vec![*connection_id], &encryption_key)
.expect("Error applying prids to page");
temp_page.to_private_page_data(dsnp_version_config, &encryption_key)
},
Expand Down

0 comments on commit 7bff885

Please sign in to comment.