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>
Get the root hash and a proof of the last leaf node.
sourcepub fn proof_range(&self, indices: Range<usize>) -> Result<CommitProof>
pub fn proof_range(&self, indices: Range<usize>) -> Result<CommitProof>
Get a proof for the given range.
sourcepub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof>
pub fn proof(&self, leaf_indices: &[usize]) -> Result<CommitProof>
Get a 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 root(&self) -> Option<<Sha256 as Hasher>::Hash>
pub fn root(&self) -> Option<<Sha256 as Hasher>::Hash>
Get the root hash of the underlying merkle tree.
sourcepub fn root_hex(&self) -> Option<String>
pub fn root_hex(&self) -> Option<String>
Get the root hash of the underlying merkle tree as hexadecimal.
sourcepub fn relationship(
&self,
other_proof: CommitProof,
match_proof: Option<CommitProof>
) -> Result<CommitRelationship>
pub fn relationship( &self, other_proof: CommitProof, match_proof: Option<CommitProof> ) -> Result<CommitRelationship>
Get the commit relationship from the proof in another tree and a match proof which indicates whether the current head proof of this tree is contained in the other 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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.