pub struct MemoryDAGStore {
nodes: HashMap<Hash, MerkleNode>,
heads: HashSet<Hash>,
children_index: HashMap<Hash, HashSet<Hash>>,
missing: HashSet<Hash>,
cached_topo_order: RwLock<Option<Vec<Hash>>>,
}Expand description
In-memory implementation of DAGStore.
Fields§
§nodes: HashMap<Hash, MerkleNode>All nodes indexed by CID.
heads: HashSet<Hash>Current heads (nodes without children).
children_index: HashMap<Hash, HashSet<Hash>>Reverse index: parent -> children.
missing: HashSet<Hash>Referenced but missing nodes.
cached_topo_order: RwLock<Option<Vec<Hash>>>Cached topological order (invalidated on put/put_unchecked).
Implementations§
Source§impl MemoryDAGStore
impl MemoryDAGStore
Sourcepub fn with_genesis(creator: impl Into<String>) -> (Self, Hash)
pub fn with_genesis(creator: impl Into<String>) -> (Self, Hash)
Create a store with a genesis node.
Sourcefn update_heads(&mut self, node: &MerkleNode)
fn update_heads(&mut self, node: &MerkleNode)
Update the heads set after adding a node.
Sourcefn update_children_index(&mut self, node: &MerkleNode)
fn update_children_index(&mut self, node: &MerkleNode)
Update the children index after adding a node.
Sourcefn compute_max_depth(&self) -> usize
fn compute_max_depth(&self) -> usize
Compute the maximum depth of the DAG.
Sourcefn compute_branching_stats(&self) -> f64
fn compute_branching_stats(&self) -> f64
Compute average branching factor.
Trait Implementations§
Source§impl Clone for MemoryDAGStore
impl Clone for MemoryDAGStore
Source§impl DAGStore for MemoryDAGStore
impl DAGStore for MemoryDAGStore
Source§fn put(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
fn put(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
Store a node, returning its CID. Read more
Source§fn put_unchecked(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
fn put_unchecked(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
Store a node without checking for missing parents. Read more
Source§fn ancestors(&self, cid: &Hash) -> HashSet<Hash>
fn ancestors(&self, cid: &Hash) -> HashSet<Hash>
Get all ancestors of a node (transitive closure).
Source§fn topological_order(&self) -> Vec<Hash>
fn topological_order(&self) -> Vec<Hash>
Get all nodes in topological order (parents before children).
Source§fn missing_nodes(&self) -> HashSet<Hash>
fn missing_nodes(&self) -> HashSet<Hash>
Get nodes that are missing (referenced but not present).
Source§impl Debug for MemoryDAGStore
impl Debug for MemoryDAGStore
Source§impl Default for MemoryDAGStore
impl Default for MemoryDAGStore
Source§fn default() -> MemoryDAGStore
fn default() -> MemoryDAGStore
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MemoryDAGStore
impl<'de> Deserialize<'de> for MemoryDAGStore
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
Auto Trait Implementations§
impl !Freeze for MemoryDAGStore
impl RefUnwindSafe for MemoryDAGStore
impl Send for MemoryDAGStore
impl Sync for MemoryDAGStore
impl Unpin for MemoryDAGStore
impl UnwindSafe for MemoryDAGStore
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