pub struct MerkleState {
pub tree: MerkleTree,
}Fields§
§tree: MerkleTreeImplementations§
Source§impl MerkleState
impl MerkleState
Sourcepub fn from_db(db: &Database) -> Result<Self>
pub fn from_db(db: &Database) -> Result<Self>
Rebuild the Merkle tree from every entry in the database. O(N) on startup; subsequent appends are O(log N).
Leaf hashes cover the entry’s sequence, timestamp, and artifact hash, so the rebuild reuses the stored timestamps — freshly stamped ones would silently change every leaf and invalidate every proof issued before the restart.
Sourcepub fn append(
&mut self,
leaf: Hash,
artifact_type: ArtifactType,
timestamp: DateTime<Utc>,
) -> u64
pub fn append( &mut self, leaf: Hash, artifact_type: ArtifactType, timestamp: DateTime<Utc>, ) -> u64
Append one leaf. The timestamp must be the same one stored in the database for this entry — the two must never diverge or a later rebuild produces a different tree.
pub fn root(&self) -> Hash
pub fn len(&self) -> u64
pub fn inclusion_proof( &self, sequence: u64, ) -> Result<InclusionProof, MerkleError>
pub fn consistency_proof(&self, old_size: u64) -> Result<Vec<Hash>, MerkleError>
Auto Trait Implementations§
impl Freeze for MerkleState
impl RefUnwindSafe for MerkleState
impl Send for MerkleState
impl Sync for MerkleState
impl Unpin for MerkleState
impl UnsafeUnpin for MerkleState
impl UnwindSafe for MerkleState
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