mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 20:41:22 +00:00
Address Eirik's review comments
This commit is contained in:
@@ -90,10 +90,10 @@ impl<Node: Hashable> CommitmentTree<Node> {
|
||||
/// Returns the number of notes in the tree.
|
||||
pub fn size(&self) -> usize {
|
||||
self.parents.iter().enumerate().fold(
|
||||
match (self.left.is_some(), self.right.is_some()) {
|
||||
(false, false) => 0,
|
||||
(true, false) | (false, true) => 1,
|
||||
(true, true) => 2,
|
||||
match (self.left, self.right) {
|
||||
(None, None) => 0,
|
||||
(Some(_), None) | (None, Some(_)) => 1,
|
||||
(Some(_), Some(_)) => 2,
|
||||
},
|
||||
|acc, (i, p)| {
|
||||
// Treat occupation of parents array as a binary number
|
||||
|
@@ -221,6 +221,7 @@ mod tests {
|
||||
eval_u8!(Some(1), [1, 1]);
|
||||
eval_u8!(Some(5), [1, 5]);
|
||||
|
||||
eval_vec!(None as Option<Vec<_>>, [0]);
|
||||
eval_vec!(Some(vec![]), [1, 0]);
|
||||
eval_vec!(Some(vec![0]), [1, 1, 0]);
|
||||
eval_vec!(Some(vec![1]), [1, 1, 1]);
|
||||
|
Reference in New Issue
Block a user