fix: replace all unstable is_multiple_of with modulo operator

Rust's is_multiple_of is an unstable feature (issue #128101).
Replace with standard modulo operator for compatibility with stable Rust.
This commit is contained in:
Gulshan Yadav 2026-02-02 01:28:26 +05:30
parent 5ff415deb8
commit 8bdd28e455
5 changed files with 6 additions and 6 deletions

View file

@ -494,7 +494,7 @@ async fn import_blocks(
errors += 1;
} else {
imported += 1;
if imported.is_multiple_of(1000) {
if imported % 1000 == 0 {
info!("Imported {} blocks...", imported);
}
}
@ -586,7 +586,7 @@ async fn export_blocks(
writer.write_all(&serialized)?;
exported += 1;
if exported.is_multiple_of(1000) {
if exported % 1000 == 0 {
info!("Exported {} blocks...", exported);
}
}

View file

@ -166,7 +166,7 @@ impl KHeavyHash {
}
// Report progress every 10000 hashes
if tried.is_multiple_of(10000) && !callback(tried, nonce) {
if tried % 10000 == 0 && !callback(tried, nonce) {
return None; // Cancelled
}
}

View file

@ -282,7 +282,7 @@ impl BlockMiner {
nonce = nonce.wrapping_add(1);
// Update stats periodically
if hashes.is_multiple_of(10000) {
if hashes % 10000 == 0 {
self.hash_counter.fetch_add(10000, Ordering::Relaxed);
}
}

View file

@ -139,7 +139,7 @@ impl Chunker {
pub fn chunk_count(&self, file_size: u64) -> u32 {
let size = file_size as usize;
let full_chunks = size / self.config.chunk_size;
let has_remainder = !size.is_multiple_of(self.config.chunk_size);
let has_remainder = size % self.config.chunk_size != 0;
(full_chunks + if has_remainder { 1 } else { 0 }) as u32
}

View file

@ -187,7 +187,7 @@ impl MerkleTree {
let mut level_size = self.leaf_count;
while level_size > 1 {
let sibling_idx = if idx.is_multiple_of(2) {
let sibling_idx = if idx % 2 == 0 {
idx + 1
} else {
idx - 1