diff --git a/zcash_primitives/src/merkle_tree.rs b/zcash_primitives/src/merkle_tree.rs index e48f8ee..118d7db 100644 --- a/zcash_primitives/src/merkle_tree.rs +++ b/zcash_primitives/src/merkle_tree.rs @@ -87,13 +87,14 @@ impl CommitmentTree { }) } - /// Returns the number of notes in the tree. + /// Returns the number of leaf nodes in the tree. pub fn size(&self) -> usize { self.parents.iter().enumerate().fold( match (self.left, self.right) { (None, None) => 0, - (Some(_), None) | (None, Some(_)) => 1, + (Some(_), None) => 1, (Some(_), Some(_)) => 2, + (None, Some(_)) => unreachable!(), }, |acc, (i, p)| { // Treat occupation of parents array as a binary number @@ -110,7 +111,7 @@ impl CommitmentTree { && self.parents.iter().all(|p| p.is_some()) } - /// Adds a note to the tree. + /// Adds a leaf node to the tree. /// /// Returns an error if the tree is full. pub fn append(&mut self, node: Node) -> Result<(), ()> { @@ -269,7 +270,7 @@ impl IncrementalWitness { Optional::write(&mut writer, &self.cursor, |w, t| t.write(w)) } - /// Returns the position of the witnessed note in the commitment tree. + /// Returns the position of the witnessed leaf node in the commitment tree. pub fn position(&self) -> usize { self.tree.size() - 1 } @@ -328,7 +329,7 @@ impl IncrementalWitness { d + skip } - /// Tracks a note that has been added to the underlying tree. + /// Tracks a leaf node that has been added to the underlying tree. /// /// Returns an error if the tree is full. pub fn append(&mut self, node: Node) -> Result<(), ()> {