Address Eirik's review comments

This commit is contained in:
Jack Grigg
2019-06-03 11:14:01 +01:00
parent 79006ecbdf
commit 07dbfbef59
2 changed files with 5 additions and 4 deletions

View File

@@ -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