Skip to content

Commit

Permalink
populate orchard note commitment trees
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Apr 2, 2024
1 parent a3b4de0 commit 370a4aa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions zcash_client_backend/src/data_api/mem_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,21 @@ impl WalletWrite for MemoryWalletDb {

self.blocks.insert(block.block_height, memory_block);

// Add the sapling commitments to the sapling tree.
let sapling_block_commitments = block.into_commitments().sapling;
// Add the Sapling commitments to the sapling tree.
let block_commitments = block.into_commitments();
let sapling_block_commitments = block_commitments.sapling;
sapling_block_commitments.iter().map(|(node, height)| {
self.sapling_tree.append(*node, *height);
});

// TODO: Add orchard commitments to the orchard tree.
#[cfg(feature = "orchard")]
{
// Add the Orchard commitments to the sapling tree.
let orchard_block_commitments = block_commitments.orchard;
orchard_block_commitments.iter().map(|(node, height)| {
self.orchard_tree.append(*node, *height);

This comment has been minimized.

Copy link
@nuttycom

nuttycom Apr 2, 2024

Contributor

You might consider using batch_insert instead: https://github.com/zcash/incrementalmerkletree/blob/main/shardtree/src/batch.rs#L40 - this will both be more performant and it will avoid errors by ensuring you're inserting the note commitments at the correct spot in the tree.

This comment has been minimized.

Copy link
@oxarbitrage

oxarbitrage Apr 2, 2024

Author Contributor

Ok, thank you fort that, i used it b1a0fcc but i am not totally sure if it is correct.

});
}

// TODO: Received notes need to be made available for note selection & balance calculation

Expand Down

0 comments on commit 370a4aa

Please sign in to comment.