cleanup path fn and add test coverage (#1201)

This commit is contained in:
Antioch Peverell
2018-06-26 09:42:12 -04:00
committed by GitHub
parent 8ff8c8a128
commit 14667bfad6
2 changed files with 11 additions and 6 deletions
+3 -6
View File
@@ -712,14 +712,11 @@ pub fn is_left_sibling(pos: u64) -> bool {
/// The size (and therefore the set of peaks) of the MMR
/// is defined by last_pos.
pub fn path(pos: u64, last_pos: u64) -> Vec<u64> {
let mut path = vec![pos];
let mut path = vec![];
let mut current = pos;
while current + 1 <= last_pos {
while current <= last_pos {
path.push(current);
let (parent, _) = family(current);
if parent > last_pos {
break;
}
path.push(parent);
current = parent;
}
path