fix: add start index

This commit is contained in:
rymnc 2023-05-09 13:52:06 +05:30
parent 93ccd0b594
commit 12174845f9
No known key found for this signature in database
GPG Key ID: C740033EE3F41EBD
2 changed files with 4 additions and 3 deletions

View File

@ -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() {

View File

@ -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(),