Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/function/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where

let shallow_update = self.shallow_verify_memo(zalsa, database_key_index, memo)?;

if self.validate_may_be_provisional(db, zalsa, database_key_index, memo) {
if !memo.may_be_provisional() {
self.update_shallow(db, zalsa, database_key_index, memo, shallow_update);

// SAFETY: memo is present in memo_map and we have verified that it is
Expand Down
20 changes: 10 additions & 10 deletions src/function/maybe_changed_after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ where

if let Some(shallow_update) = self.shallow_verify_memo(zalsa, database_key_index, memo)
{
if self.validate_may_be_provisional(db, zalsa, database_key_index, memo) {
if !memo.may_be_provisional() {
self.update_shallow(db, zalsa, database_key_index, memo, shallow_update);

return if memo.revisions.changed_at > revision {
Expand Down Expand Up @@ -236,9 +236,11 @@ where
}
}

/// Validates this memo if it is a provisional memo. Returns true for non provisional memos or
/// if the provisional memo has been successfully marked as verified final, that is, its
/// cycle heads have all been finalized.
/// Validates this memo if it is a provisional memo. Returns true for:
/// * non provisional memos
/// * provisional memos that have been successfully marked as verified final, that is, its
/// cycle heads have all been finalized.
/// * provisional memos that have been created in the same revision and iteration and are part of the same cycle.
#[inline]
pub(super) fn validate_may_be_provisional(
&self,
Expand All @@ -247,9 +249,9 @@ where
database_key_index: DatabaseKeyIndex,
memo: &Memo<C::Output<'_>>,
) -> bool {
// Wouldn't it be nice if rust had an implication operator ...
// may_be_provisional -> validate_provisional
!memo.may_be_provisional() || self.validate_provisional(db, zalsa, database_key_index, memo)
!memo.may_be_provisional()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment for this method (above and unchanged in the PR, so I can't inline-comment on it directly) needs to be updated to mention the same-iteration caveat.

|| self.validate_provisional(db, zalsa, database_key_index, memo)
|| self.validate_same_iteration(db, database_key_index, memo)
}

/// Check if this memo's cycle heads have all been finalized. If so, mark it verified final and
Expand Down Expand Up @@ -353,9 +355,7 @@ where
let shallow_update = self.shallow_verify_memo(zalsa, database_key_index, old_memo);
let shallow_update_possible = shallow_update.is_some();
if let Some(shallow_update) = shallow_update {
if self.validate_may_be_provisional(db, zalsa, database_key_index, old_memo)
|| self.validate_same_iteration(db, database_key_index, old_memo)
{
if self.validate_may_be_provisional(db, zalsa, database_key_index, old_memo) {
self.update_shallow(db, zalsa, database_key_index, old_memo, shallow_update);

return VerifyResult::unchanged();
Expand Down