Struct sos_sdk::commit::CommitTree
source · 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 insert(&mut self, hash: <Sha256 as Hasher>::Hash) -> &mut Self
pub fn insert(&mut self, hash: <Sha256 as Hasher>::Hash) -> &mut Self
Insert a commit hash into the tree,
sourcepub fn append(
&mut self,
hashes: &mut Vec<<Sha256 as Hasher>::Hash>
) -> &mut Self
pub fn append( &mut self, hashes: &mut Vec<<Sha256 as Hasher>::Hash> ) -> &mut Self
Append a collections of commit hashes to the tree.
sourcepub fn head(&self) -> Result<CommitProof>
pub fn head(&self) -> Result<CommitProof>
Root hash and a proof of the last leaf node.
sourcepub fn proof_at(&self, commit: &CommitHash) -> Result<CommitProof>
pub fn proof_at(&self, commit: &CommitHash) -> Result<CommitProof>
Get a proof up to a particular commit.
sourcepub fn proof_range(&self, indices: Range<usize>) -> Result<CommitProof>
pub fn proof_range(&self, indices: Range<usize>) -> Result<CommitProof>
Proof for the given range.
sourcepub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof>
pub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof>
Proof for the given indices.
sourcepub fn compare(&self, proof: &CommitProof) -> Result<Comparison>
pub fn compare(&self, proof: &CommitProof) -> Result<Comparison>
Compare this tree against another root hash and merkle proof.
sourcepub fn first_commit(&self) -> Result<CommitState>
pub fn first_commit(&self) -> Result<CommitState>
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>
pub fn commit_state(&self) -> Result<CommitState>
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 contains(&self, other_proof: &CommitProof) -> Result<Option<CommitProof>>
pub fn contains(&self, other_proof: &CommitProof) -> Result<Option<CommitProof>>
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 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