pub struct MerkleNode {
pub cid: Hash,
pub parents: Vec<Hash>,
pub payload: Payload,
pub timestamp: u64,
pub creator: String,
}Expand description
A node in the Merkle-DAG representing a causal event.
The node’s CID is computed from its contents, making it content-addressed and tamper-proof. Any change to the node’s data would change its CID.
Fields§
§cid: HashContent identifier - SHA-256 hash of the node’s contents. This is computed when the node is built.
parents: Vec<Hash>Hashes of parent nodes (causal predecessors). Empty for genesis nodes.
payload: PayloadThe payload carried by this node.
timestamp: u64Logical timestamp (monotonically increasing per replica).
creator: StringThe replica that created this node.
Implementations§
Source§impl MerkleNode
impl MerkleNode
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Check if this is a genesis node.
Sourcepub fn has_parent(&self, cid: &Hash) -> bool
pub fn has_parent(&self, cid: &Hash) -> bool
Check if this node is a descendant of another (has it as ancestor). Note: This only checks direct parents, not transitive ancestry.
Sourcepub fn parent_count(&self) -> usize
pub fn parent_count(&self) -> usize
Get the number of parents (branching factor for this node).
Trait Implementations§
Source§impl Clone for MerkleNode
impl Clone for MerkleNode
Source§fn clone(&self) -> MerkleNode
fn clone(&self) -> MerkleNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MerkleNode
impl Debug for MerkleNode
Source§impl<'de> Deserialize<'de> for MerkleNode
impl<'de> Deserialize<'de> for MerkleNode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MerkleNode
impl PartialEq for MerkleNode
Source§impl Serialize for MerkleNode
impl Serialize for MerkleNode
impl Eq for MerkleNode
impl StructuralPartialEq for MerkleNode
Auto Trait Implementations§
impl Freeze for MerkleNode
impl RefUnwindSafe for MerkleNode
impl Send for MerkleNode
impl Sync for MerkleNode
impl Unpin for MerkleNode
impl UnwindSafe for MerkleNode
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