Skip to content

Commit

Permalink
Fix right-shifting to zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe committed May 1, 2024
1 parent 521a7d8 commit cf50743
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arbitrator/prover/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use enum_iterator::Sequence;
#[cfg(feature = "counters")]
use enum_iterator::all;

use std::cmp::max;
use std::cmp::Ordering;
#[cfg(feature = "counters")]
use std::sync::atomic::AtomicUsize;
Expand Down Expand Up @@ -347,7 +348,7 @@ impl Merkle {
let mut new_size = idx + hashes.len();
for (layer_i, layer) in self.layers.iter_mut().enumerate() {
layer.resize(new_size, self.empty_layers[layer_i]);
new_size >>= 1;
new_size = max(new_size >> 1, 1);
}
for hash in hashes {
self.set(idx, hash);
Expand Down

0 comments on commit cf50743

Please sign in to comment.