diff --git a/nym-api/src/ecash/state/local.rs b/nym-api/src/ecash/state/local.rs index 7c40e9d98b..7e504f1c14 100644 --- a/nym-api/src/ecash/state/local.rs +++ b/nym-api/src/ecash/state/local.rs @@ -127,7 +127,7 @@ impl DailyMerkleTree { pub(crate) fn maybe_rebuild(&mut self) { // every 1000 leaves, rebuild the tree to purge the history // (I wish the API of the library allowed to do it without having to go through those extra steps...) - if !self.inserted_leaves.is_empty() && self.inserted_leaves.len() % 1000 == 0 { + if !self.inserted_leaves.is_empty() && self.inserted_leaves.len().is_multiple_of(1000) { self.rebuild_without_history(); } } diff --git a/nym-api/src/ecash/state/mod.rs b/nym-api/src/ecash/state/mod.rs index 5e26c937b9..3aecfc3811 100644 --- a/nym-api/src/ecash/state/mod.rs +++ b/nym-api/src/ecash/state/mod.rs @@ -803,7 +803,7 @@ impl EcashState { merkle_entry.maybe_rebuild(); // toss a coin to check if we should clean memory of old merkle trees - if thread_rng().next_u32() % 10000 == 0 { + if thread_rng().next_u32().is_multiple_of(10000) { let mut values_to_clean = Vec::new(); let cutoff = self.config.ticketbook_retention_cutoff(); info!("attempting to remove old issued ticketbooks. the cutoff is set to {cutoff}");