mirror of
https://github.com/vacp2p/pmtree.git
synced 2025-02-22 12:08:31 +00:00
fix: add start index
This commit is contained in:
parent
93ccd0b594
commit
12174845f9
@ -252,13 +252,14 @@ where
|
||||
|
||||
pub fn batch_operations<I: IntoIterator<Item = H::Fr>, J: IntoIterator<Item = usize>>(
|
||||
&mut self,
|
||||
start: Option<usize>,
|
||||
leaves: I,
|
||||
to_remove_indices: J,
|
||||
) -> PmtreeResult<()> {
|
||||
let leaves = leaves.into_iter().collect::<Vec<_>>();
|
||||
let to_remove_indices = to_remove_indices.into_iter().collect::<Vec<_>>();
|
||||
|
||||
let start = self.next_index;
|
||||
let start = start.unwrap_or(self.next_index);
|
||||
let end = start + leaves.len();
|
||||
|
||||
if end - to_remove_indices.len() > self.capacity() {
|
||||
|
@ -223,14 +223,14 @@ fn batch_operations() -> PmtreeResult<()> {
|
||||
hex!("0000000000000000000000000000000000000000000000000000000000000004"),
|
||||
];
|
||||
|
||||
mt.batch_operations(leaves, [])?;
|
||||
mt.batch_operations(None, leaves, [])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
hex!("a9bb8c3f1f12e9aa903a50c47f314b57610a3ab32f2d463293f58836def38d36")
|
||||
);
|
||||
|
||||
mt.batch_operations([], [0, 1, 2, 3])?;
|
||||
mt.batch_operations(None, [], [0, 1, 2, 3])?;
|
||||
|
||||
assert_eq!(
|
||||
mt.root(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user