Fill in more documentation

This commit is contained in:
Jeremy Wall 2022-08-04 20:15:57 -04:00
parent 3f2ddf308b
commit 4e18982d0c
2 changed files with 7 additions and 0 deletions

View File

@ -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<u8>;
}

View File

@ -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<N, HW, HASH_LEN>> {
&self.nodes
}