Skip to content

Commit

Permalink
Merge pull request #49 from Davidson-Souza/fix/linting
Browse files Browse the repository at this point in the history
fix some linting suggestions
  • Loading branch information
Davidson-Souza authored Jun 8, 2024
2 parents d8a1aea + 40306cd commit e12ab84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/accumulator/pollard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ impl Node {
.replace(NodeHash::parent_hash(&left.data.get(), &right.data.get()));
}
if let Some(ref parent) = *self.parent.borrow() {
parent.upgrade().and_then(|p| {
if let Some(p) = parent.upgrade() {
p.recompute_hashes();
Some(())
});
}
}
}
/// Writes one node to the writer, this method will recursively write all children.
Expand Down Expand Up @@ -344,17 +343,19 @@ impl Pollard {
for row in (0..(branch_len)).rev() {
// Parent is the sibling of the current node as each of the
// nodes point to their nieces.
parent = sibling;
parent.clone_from(&sibling);

// Figure out which node we need to follow.
let niece_pos = ((bits >> row) & 1) as u8;

#[allow(clippy::assigning_clones)]
if let Some(node) = n {
if is_left_niece(niece_pos as u64) {
n = node.right.borrow().clone();
sibling = node.left.borrow().clone();
sibling.clone_from(&*node.left.borrow());
} else {
n = node.left.borrow().clone();
sibling = node.right.borrow().clone();
sibling.clone_from(&*node.right.borrow());
}
} else {
sibling = None;
Expand Down Expand Up @@ -410,8 +411,7 @@ impl Pollard {
while let Some(parent) = node.parent.clone().into_inner() {
let parent_left = parent
.upgrade()
.map(|parent| parent.left.clone().into_inner())
.flatten()
.and_then(|parent| parent.left.clone().into_inner())
.unwrap()
.clone();

Expand Down
4 changes: 2 additions & 2 deletions src/accumulator/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pub fn is_root_position(position: u64, num_leaves: u64, forest_rows: u8) -> bool
// bit is to be removed from 1011 (11 in dec), the returned value is 111 (7 in dec).
pub fn remove_bit(val: u64, bit: u64) -> u64 {
let mask = ((2 << bit) - 1) as u64;
let upper_mask = std::u64::MAX ^ mask;
let upper_mask = u64::MAX ^ mask;
let upper = val & upper_mask;

let mask = ((1 << bit) - 1) as u64;
let lower_mask = !(std::u64::MAX ^ mask);
let lower_mask = !(u64::MAX ^ mask);
let lower = val & lower_mask;

(upper >> 1) | lower
Expand Down

0 comments on commit e12ab84

Please sign in to comment.