Skip to content

Commit

Permalink
simplify flush checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Sep 5, 2023
1 parent 58e0668 commit 3b095ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions stylus-sdk/src/call/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum CallKind {

/// How to manage the storage cache, if enabled.
#[allow(unused)]
#[derive(Clone, Default, PartialEq, PartialOrd)]
#[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) enum CachePolicy {
#[default]
DoNothing,
Expand Down Expand Up @@ -128,9 +128,7 @@ impl RawCall {
/// Write all cached values to persistent storage before the call.
#[cfg(feature = "storage-cache")]
pub fn flush_storage_cache(mut self) -> Self {
if self.cache_policy < CachePolicy::Flush {
self.cache_policy = CachePolicy::Flush;
}
self.cache_policy = self.cache_policy.max(CachePolicy::Flush);
self
}

Expand Down
4 changes: 1 addition & 3 deletions stylus-sdk/src/deploy/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ impl RawDeploy {
/// Write all cached values to persistent storage before the init code.
#[cfg(feature = "storage-cache")]
pub fn flush_storage_cache(mut self) -> Self {
if self.cache_policy < CachePolicy::Flush {
self.cache_policy = CachePolicy::Flush;
}
self.cache_policy = self.cache_policy.max(CachePolicy::Flush);
self
}

Expand Down

0 comments on commit 3b095ac

Please sign in to comment.