Skip to content

Commit

Permalink
feat: implement Block::build_note_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
polydez committed Apr 26, 2024
1 parent 9294e9f commit 11a75e5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions objects/src/block/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use alloc::vec::Vec;

use miden_crypto::merkle::MerkleError;

use super::{Digest, Felt, Hasher, ZERO};

mod header;
Expand Down Expand Up @@ -102,6 +104,15 @@ impl Block {
})
}

/// Returns a note tree containing all notes created in this block.
pub fn build_note_tree(&self) -> Result<BlockNoteTree, MerkleError> {
let entries = self
.notes()
.map(|(note_index, note)| (note_index, note.id().into(), *note.metadata()));

BlockNoteTree::with_entries(entries)
}

/// Returns a set of nullifiers for all notes consumed in the block.
pub fn created_nullifiers(&self) -> &[Nullifier] {
&self.created_nullifiers
Expand Down

0 comments on commit 11a75e5

Please sign in to comment.