feat: add merkle path containers and return them on tree update

Returning tuples is often confusing as they don't convey meaning and it
should be used only when there is no possible ambiguity.

For `MerkleStore`, we had a couple of tuples being returned, and reading
the implementation was required in order to distinguish if they were
leaf values or computed roots.

This commit introduces two containers that will self-document these
returns: `RootPath` and `ValuePath`. It will also update `set_node` to
return both the new root & the new path, so we can prevent duplicated
traversals downstream when updating a node (one to update, the second to
fetch the new path/root).
This commit is contained in:
Victor Lopez
2023-03-21 10:40:48 +01:00
parent f07ed69d2f
commit 84086bdb95
4 changed files with 80 additions and 45 deletions

View File

@@ -18,7 +18,7 @@ mod merkle_tree;
pub use merkle_tree::MerkleTree;
mod path;
pub use path::MerklePath;
pub use path::{MerklePath, RootPath, ValuePath};
mod path_set;
pub use path_set::MerklePathSet;