SparseMerklePath: add SparseValuePath container
This commit is contained in:
parent
c45d9682eb
commit
cc6981de7f
1 changed files with 27 additions and 0 deletions
|
@ -254,6 +254,33 @@ impl DoubleEndedIterator for SparseMerkleIter {
|
|||
}
|
||||
}
|
||||
|
||||
// SPARSE MERKLE PATH CONTAINERS
|
||||
// ================================================================================================
|
||||
/// A container for a [crate::Word] value and its [SparseMerklePath] opening.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct SparseValuePath {
|
||||
/// The node value opening for `path`.
|
||||
pub value: RpoDigest,
|
||||
/// The path from `value` to `root` (exclusive), using an efficient memory representation for
|
||||
/// empty nodes.
|
||||
pub path: SparseMerklePath,
|
||||
}
|
||||
|
||||
impl SparseValuePath {
|
||||
/// Convenience function to construct a [SparseValuePath].
|
||||
///
|
||||
/// `value` is the value `path` leads to, in the tree.
|
||||
pub fn new(value: RpoDigest, path: SparseMerklePath) -> Self {
|
||||
Self { value, path }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(SparseMerklePath, Word)> for SparseValuePath {
|
||||
fn from((path, value): (SparseMerklePath, Word)) -> Self {
|
||||
SparseValuePath::new(value.into(), path)
|
||||
}
|
||||
}
|
||||
|
||||
// SERIALIZATION
|
||||
// ================================================================================================
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue