Skip to main content

miden_node_store/state/view/
note.rs

1//! Note reads.
2//!
3//! These are content-addressed lookups and technically not block-scoped, but they live on
4//! [`StateView`] so that every read path flows through the same type.
5
6use miden_protocol::Word;
7use miden_protocol::note::{NoteId, NoteScript};
8
9use super::StateView;
10use crate::db::NoteRecord;
11use crate::errors::DatabaseError;
12
13impl StateView {
14    /// Queries a list of notes from the database.
15    ///
16    /// If the provided list of [`NoteId`]s is empty or no note matches, an empty list is
17    /// returned. This lookup is deliberately not bounded by this view's tip (latest-wins): a note
18    /// committed while a block is being applied may be returned before the snapshot advances.
19    pub async fn get_notes_by_id(
20        &self,
21        note_ids: Vec<NoteId>,
22    ) -> Result<Vec<NoteRecord>, DatabaseError> {
23        self.db.select_notes_by_id(note_ids).await
24    }
25
26    /// Returns the script for a note by its root.
27    pub async fn get_note_script_by_root(
28        &self,
29        root: Word,
30    ) -> Result<Option<NoteScript>, DatabaseError> {
31        self.db.select_note_script_by_root(root).await
32    }
33}