Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some linting suggestions #49

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading