diff --git a/src/hash.rs b/src/hash.rs index 493ed68..9e94565 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -16,6 +16,7 @@ use std::hash::Hasher; /// Utility Trait to specify that payloads must be serializable into bytes. pub trait ByteEncoder { + /// Serialize self into bytes. fn bytes(&self) -> Vec; } diff --git a/src/lib.rs b/src/lib.rs index baa75ae..d3ec346 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,10 @@ use node::Node; mod hash; mod node; +/// Node comparison values. In a given Merkle DAG a Node can come `After`, `Before`, be `Equivalent`, or `Uncomparable`. +/// If the two nodes have the same id they are eqivalent. If two nodes are not part of the same sub graph within the DAG +/// then they are Uncomparable. If one node is an ancestor of another DAG then that node comes before the other. If the +/// reverse is true then that node comes after the other. #[derive(PartialEq, Debug)] pub enum NodeCompare { After, @@ -96,10 +100,12 @@ where self.nodes.get(id) } + /// Get the set of root node ids. pub fn get_roots(&self) -> &BTreeSet<[u8; HASH_LEN]> { &self.roots } + /// Get the map of all nodes in the DAG. pub fn get_nodes(&self) -> &BTreeMap<[u8; HASH_LEN], Node> { &self.nodes }