pub struct CommitTree { /* private fields */ }
Expand description
Encapsulates a Merkle tree and provides functions for generating and comparing proofs.
Implementations§
Source§impl CommitTree
impl CommitTree
Sourcepub fn append(&mut self, hashes: &mut Vec<TreeHash>) -> &mut Self
pub fn append(&mut self, hashes: &mut Vec<TreeHash>) -> &mut Self
Append a collections of commit hashes to the tree.
Sourcepub fn head(&self) -> Result<CommitProof, Error>
pub fn head(&self) -> Result<CommitProof, Error>
Root hash and a proof of the last leaf node.
Sourcepub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof, Error>
pub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof, Error>
Proof for the given indices.
Sourcepub fn compare(&self, proof: &CommitProof) -> Result<Comparison, Error>
pub fn compare(&self, proof: &CommitProof) -> Result<Comparison, Error>
Compare this tree against another root hash and merkle proof.
Sourcepub fn first_commit(&self) -> Result<CommitState, Error>
pub fn first_commit(&self) -> Result<CommitState, Error>
Compute the first commit state.
Must have at least one commit.
Sourcepub fn last_commit(&self) -> Option<CommitHash>
pub fn last_commit(&self) -> Option<CommitHash>
Last commit hash in the underlying merkle tree.
Sourcepub fn commit_state(&self) -> Result<CommitState, Error>
pub fn commit_state(&self) -> Result<CommitState, Error>
Commit state of this tree.
The tree must already have some commits.
Sourcepub fn root(&self) -> Option<CommitHash>
pub fn root(&self) -> Option<CommitHash>
Root hash of the underlying merkle tree.
Sourcepub fn root_hex(&self) -> Option<String>
pub fn root_hex(&self) -> Option<String>
Root hash of the underlying merkle tree as hexadecimal.
Sourcepub fn contains(
&self,
other_proof: &CommitProof,
) -> Result<Option<CommitProof>, Error>
pub fn contains( &self, other_proof: &CommitProof, ) -> Result<Option<CommitProof>, Error>
Given a proof from another tree determine if this tree contains the other proof.
Trait Implementations§
Source§impl Default for CommitTree
impl Default for CommitTree
Source§fn default() -> CommitTree
fn default() -> CommitTree
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CommitTree
impl RefUnwindSafe for CommitTree
impl Send for CommitTree
impl Sync for CommitTree
impl Unpin for CommitTree
impl UnwindSafe for CommitTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more