diff --git a/src/node.rs b/src/node.rs index fb3f44a..7dda51b 100644 --- a/src/node.rs +++ b/src/node.rs @@ -120,4 +120,8 @@ where pub fn dependency_ids(&self) -> &BTreeSet> { &self.dependency_ids } + + pub fn out_degree(&self) -> usize { + self.dependency_ids.len() + } } diff --git a/src/store.rs b/src/store.rs index 6d85f7c..fd206a6 100644 --- a/src/store.rs +++ b/src/store.rs @@ -13,7 +13,7 @@ // limitations under the License. //! The MerkleDag backing store trait. -use std::collections::BTreeMap; +use std::{collections::BTreeMap, hash::Hash}; use crate::{hash::HashWriter, node::Node}; @@ -38,7 +38,9 @@ where fn store(&mut self, node: Node) -> Result<()>; } -impl Store for BTreeMap, Node> +pub type BTreeStore = BTreeMap, Node>; + +impl Store for BTreeStore where HW: HashWriter, {