@@ -90,20 +90,18 @@ where
90
90
return VerifyResult :: changed ( ) ;
91
91
} ;
92
92
93
- if let Some ( shallow_update) = self . shallow_verify_memo ( zalsa, database_key_index, memo)
94
- {
95
- if !memo. may_be_provisional ( ) {
96
- self . update_shallow ( zalsa, database_key_index, memo, shallow_update) ;
97
-
98
- return if memo. revisions . changed_at > revision {
99
- VerifyResult :: changed ( )
100
- } else {
101
- VerifyResult :: Unchanged (
102
- memo. revisions . accumulated_inputs . load ( ) ,
103
- CycleHeads :: default ( ) ,
104
- )
105
- } ;
106
- }
93
+ let can_shallow_update = self . shallow_verify_memo ( zalsa, database_key_index, memo) ;
94
+ if can_shallow_update. yes ( ) && !memo. may_be_provisional ( ) {
95
+ self . update_shallow ( zalsa, database_key_index, memo, can_shallow_update) ;
96
+
97
+ return if memo. revisions . changed_at > revision {
98
+ VerifyResult :: changed ( )
99
+ } else {
100
+ VerifyResult :: Unchanged (
101
+ memo. revisions . accumulated_inputs . load ( ) ,
102
+ CycleHeads :: default ( ) ,
103
+ )
104
+ } ;
107
105
}
108
106
109
107
if let Some ( mcs) = self . maybe_changed_after_cold (
@@ -228,7 +226,7 @@ where
228
226
zalsa : & Zalsa ,
229
227
database_key_index : DatabaseKeyIndex ,
230
228
memo : & Memo < C :: Output < ' _ > > ,
231
- ) -> Option < ShallowUpdate > {
229
+ ) -> ShallowUpdate {
232
230
tracing:: debug!(
233
231
"{database_key_index:?}: shallow_verify_memo(memo = {memo:#?})" ,
234
232
memo = memo. tracing_debug( )
@@ -238,7 +236,7 @@ where
238
236
239
237
if verified_at == revision_now {
240
238
// Already verified.
241
- return Some ( ShallowUpdate :: Verified ) ;
239
+ return ShallowUpdate :: Verified ;
242
240
}
243
241
244
242
let last_changed = zalsa. last_changed_revision ( memo. revisions . durability ) ;
@@ -251,9 +249,9 @@ where
251
249
) ;
252
250
if last_changed <= verified_at {
253
251
// No input of the suitable durability has changed since last verified.
254
- Some ( ShallowUpdate :: HigherDurability ( revision_now) )
252
+ ShallowUpdate :: HigherDurability ( revision_now)
255
253
} else {
256
- None
254
+ ShallowUpdate :: No
257
255
}
258
256
}
259
257
@@ -383,19 +381,18 @@ where
383
381
old_memo = old_memo. tracing_debug( )
384
382
) ;
385
383
386
- let shallow_update = self . shallow_verify_memo ( zalsa, database_key_index, old_memo) ;
387
- let shallow_update_possible = shallow_update. is_some ( ) ;
388
- if let Some ( shallow_update) = shallow_update {
389
- if self . validate_may_be_provisional (
384
+ let can_shallow_update = self . shallow_verify_memo ( zalsa, database_key_index, old_memo) ;
385
+ if can_shallow_update. yes ( )
386
+ && self . validate_may_be_provisional (
390
387
zalsa,
391
388
db. zalsa_local ( ) ,
392
389
database_key_index,
393
390
old_memo,
394
- ) {
395
- self . update_shallow ( zalsa, database_key_index, old_memo, shallow_update) ;
391
+ )
392
+ {
393
+ self . update_shallow ( zalsa, database_key_index, old_memo, can_shallow_update) ;
396
394
397
- return VerifyResult :: unchanged ( ) ;
398
- }
395
+ return VerifyResult :: unchanged ( ) ;
399
396
}
400
397
401
398
match & old_memo. revisions . origin {
@@ -430,7 +427,7 @@ where
430
427
431
428
// If the value is from the same revision but is still provisional, consider it changed
432
429
// because we're now in a new iteration.
433
- if shallow_update_possible && is_provisional {
430
+ if can_shallow_update . yes ( ) && is_provisional {
434
431
return VerifyResult :: changed ( ) ;
435
432
}
436
433
@@ -550,4 +547,16 @@ pub(super) enum ShallowUpdate {
550
547
/// The revision for the memo's durability hasn't changed. It can be marked as verified
551
548
/// in this revision.
552
549
HigherDurability ( Revision ) ,
550
+
551
+ /// The memo requires a deep verification.
552
+ No ,
553
+ }
554
+
555
+ impl ShallowUpdate {
556
+ pub ( super ) fn yes ( & self ) -> bool {
557
+ matches ! (
558
+ self ,
559
+ ShallowUpdate :: Verified | ShallowUpdate :: HigherDurability ( _)
560
+ )
561
+ }
553
562
}
0 commit comments