Documentation and naming for clarity

This commit is contained in:
Jeremy Wall 2022-09-18 16:56:53 -04:00
parent b12c92c9d4
commit 63fb67f7bf
2 changed files with 7 additions and 4 deletions

View File

@ -18,7 +18,8 @@ use crate::hash::HashWriter;
use crate::node::Node; use crate::node::Node;
use crate::store::{Result, Store}; use crate::store::{Result, Store};
pub struct Gap<'dag, S, HW> /// An iterator over the missing nodes in a DAG given a set of root nodes.
pub struct Missing<'dag, S, HW>
where where
S: Store<HW>, S: Store<HW>,
HW: HashWriter, HW: HashWriter,
@ -27,15 +28,17 @@ where
search_nodes: BTreeSet<Vec<u8>>, search_nodes: BTreeSet<Vec<u8>>,
} }
impl<'dag, S, HW> Gap<'dag, S, HW> impl<'dag, S, HW> Missing<'dag, S, HW>
where where
S: Store<HW>, S: Store<HW>,
HW: HashWriter, HW: HashWriter,
{ {
/// Create an Iterator for the missing nodes given a set of root nodes.
pub fn new(dag: &'dag Merkle<S, HW>, search_nodes: BTreeSet<Vec<u8>>) -> Self { pub fn new(dag: &'dag Merkle<S, HW>, search_nodes: BTreeSet<Vec<u8>>) -> Self {
Self { dag, search_nodes } Self { dag, search_nodes }
} }
/// Returns the next set of missing nodes in the iterator.
pub fn next(&mut self) -> Result<Option<Vec<Node<HW>>>> { pub fn next(&mut self) -> Result<Option<Vec<Node<HW>>>> {
let nodes = self let nodes = self
.dag .dag

View File

@ -158,11 +158,11 @@ where
pub fn gap_fill_iter<'dag, 'iter>( pub fn gap_fill_iter<'dag, 'iter>(
&'dag self, &'dag self,
search_nodes: BTreeSet<Vec<u8>>, search_nodes: BTreeSet<Vec<u8>>,
) -> Gap<'iter, S, HW> ) -> Missing<'iter, S, HW>
where where
'dag: 'iter, 'dag: 'iter,
{ {
Gap::new(self, search_nodes) Missing::new(self, search_nodes)
} }
/// Find the immediate next non descendant nodes in this graph for the given `search_nodes`. /// Find the immediate next non descendant nodes in this graph for the given `search_nodes`.