Skip to content

Commit

Permalink
fix note commitment tree starting position
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Apr 3, 2024
1 parent 2f28306 commit 588156f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions zcash_client_backend/src/data_api/mem_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,16 @@ impl WalletWrite for MemoryWalletDb {

// Add the Sapling commitments to the sapling tree.
let block_commitments = block.into_commitments();
if let Ok(Some(pos)) = self.sapling_tree.max_leaf_position(0) {
if let Some(value) = from_state.final_sapling_tree().value() {
self.sapling_tree
.batch_insert(pos, block_commitments.sapling.into_iter());
.batch_insert(value.position(), block_commitments.sapling.into_iter());
}

#[cfg(feature = "orchard")]
// Add the Orchard commitments to the orchard tree.
if let Ok(Some(pos)) = self.orchard_tree.max_leaf_position(0) {
if let Some(value) = from_state.final_orchard_tree().value() {
self.orchard_tree
.batch_insert(pos, block_commitments.orchard.into_iter());
.batch_insert(value.position(), block_commitments.orchard.into_iter());

This comment has been minimized.

Copy link
@nuttycom

nuttycom Apr 6, 2024

Contributor

This will give the position before the initial position of note commitments before you want to insert (it is the position of the last note as of the state prior to the addition of this series of blocks.)

}
}

Expand Down

0 comments on commit 588156f

Please sign in to comment.