mirror of
https://github.com/vacp2p/pmtree.git
synced 2026-01-08 23:08:02 -05:00
style: add minor changes
This commit is contained in:
24
src/tree.rs
24
src/tree.rs
@@ -192,6 +192,18 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Batch insertion from starting index
|
||||
pub fn set_range<I: IntoIterator<Item = H::Fr>>(
|
||||
&mut self,
|
||||
start: usize,
|
||||
leaves: I,
|
||||
) -> PmtreeResult<()> {
|
||||
self.batch_insert(
|
||||
Some(start),
|
||||
leaves.into_iter().collect::<Vec<_>>().as_slice(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Batch insertion, updates the tree in parallel.
|
||||
pub fn batch_insert(&mut self, start: Option<usize>, leaves: &[H::Fr]) -> PmtreeResult<()> {
|
||||
let start = start.unwrap_or(self.next_index);
|
||||
@@ -226,7 +238,6 @@ where
|
||||
)?;
|
||||
|
||||
// Update next_index value in db
|
||||
|
||||
if start + leaves.len() > self.next_index {
|
||||
self.next_index = start + leaves.len();
|
||||
self.db
|
||||
@@ -239,17 +250,6 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_range<I: IntoIterator<Item = H::Fr>>(
|
||||
&mut self,
|
||||
start: usize,
|
||||
leaves: I,
|
||||
) -> PmtreeResult<()> {
|
||||
self.batch_insert(
|
||||
Some(start),
|
||||
leaves.into_iter().collect::<Vec<_>>().as_slice(),
|
||||
)
|
||||
}
|
||||
|
||||
// Fills hashmap subtree
|
||||
fn fill_nodes(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user