pub trait DAGStore {
// Required methods
fn get(&self, cid: &Hash) -> Option<&MerkleNode>;
fn put(&mut self, node: MerkleNode) -> Result<Hash, DAGError>;
fn put_unchecked(&mut self, node: MerkleNode) -> Result<Hash, DAGError>;
fn heads(&self) -> Vec<Hash>;
fn contains(&self, cid: &Hash) -> bool;
fn ancestors(&self, cid: &Hash) -> HashSet<Hash>;
fn children(&self, cid: &Hash) -> Vec<Hash>;
fn topological_order(&self) -> Vec<Hash>;
fn missing_nodes(&self) -> HashSet<Hash>;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Trait for content-addressed DAG storage.
Required Methods§
Sourcefn get(&self, cid: &Hash) -> Option<&MerkleNode>
fn get(&self, cid: &Hash) -> Option<&MerkleNode>
Get a node by its CID.
Sourcefn put(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
fn put(&mut self, node: MerkleNode) -> Result<Hash, DAGError>
Store a node, returning its CID.
The node’s CID is verified before storage. Returns an error if verification fails or parents are missing.
Sourcefn 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.
Used during sync when parents may arrive out of order.
Sourcefn ancestors(&self, cid: &Hash) -> HashSet<Hash>
fn ancestors(&self, cid: &Hash) -> HashSet<Hash>
Get all ancestors of a node (transitive closure).
Sourcefn topological_order(&self) -> Vec<Hash>
fn topological_order(&self) -> Vec<Hash>
Get all nodes in topological order (parents before children).
Sourcefn missing_nodes(&self) -> HashSet<Hash>
fn missing_nodes(&self) -> HashSet<Hash>
Get nodes that are missing (referenced but not present).