Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Oct 24, 2024
1 parent d1de37d commit 7881538
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/chia-datalayer/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl MerkleBlob {

// TODO: can we insert the top node first? maybe more efficient to update it's children
// than to update the parents of the children when traversing leaf to sub-root?
while !indexes.is_empty() {
while indexes.len() > 1 {
let mut new_indexes = vec![];

for chunk in indexes.chunks(2) {
Expand Down Expand Up @@ -2019,4 +2019,15 @@ mod tests {
blob.insert(0, 0, &[0u8; 32], InsertLocation::Auto {})
.expect_err("");
}

#[rstest]
fn test_batch_insert_with_odd_count_does_not_hang(mut small_blob: MerkleBlob) {
let mut batch: Vec<((KvId, KvId), Hash)> = vec![];

for i in 0..9 {
batch.push(((i, i), sha256_num(i)));
}

small_blob.batch_insert(batch.into_iter()).unwrap();
}
}

0 comments on commit 7881538

Please sign in to comment.