pub struct Db { /* private fields */ }Expand description
The Store’s database.
Extends the underlying miden_node_db::Db type with functionality specific to the Store.
Implementations§
Source§impl Db
impl Db
Sourcepub fn bootstrap(
database_filepath: PathBuf,
genesis: GenesisBlock,
) -> Result<()>
pub fn bootstrap( database_filepath: PathBuf, genesis: GenesisBlock, ) -> Result<()>
Creates a new database and inserts the genesis block.
Sourcepub async fn load(database_filepath: PathBuf) -> Result<Self, DatabaseError>
pub async fn load(database_filepath: PathBuf) -> Result<Self, DatabaseError>
Open a connection to the DB after verifying that it is at the latest schema version.
Sourcepub async fn load_with_pool_size(
database_filepath: PathBuf,
connection_pool_size: NonZeroUsize,
) -> Result<Self, DatabaseError>
pub async fn load_with_pool_size( database_filepath: PathBuf, connection_pool_size: NonZeroUsize, ) -> Result<Self, DatabaseError>
Open a connection to the DB with a specific pool size after verifying that it is at the latest schema version.
Sourcepub fn migrate(database_filepath: impl AsRef<Path>) -> Result<(), DatabaseError>
pub fn migrate(database_filepath: impl AsRef<Path>) -> Result<(), DatabaseError>
Applies all pending migrations to an existing DB.
Sourcepub async fn select_nullifiers_paged(
&self,
page_size: NonZeroUsize,
after_nullifier: Option<Nullifier>,
) -> Result<NullifiersPage, DatabaseError>
pub async fn select_nullifiers_paged( &self, page_size: NonZeroUsize, after_nullifier: Option<Nullifier>, ) -> Result<NullifiersPage, DatabaseError>
Returns a page of nullifiers for tree rebuilding.
Sourcepub async fn select_nullifiers_by_prefix(
&self,
prefix_len: u32,
nullifier_prefixes: Vec<u32>,
block_range: RangeInclusive<BlockNumber>,
) -> Result<(Vec<NullifierInfo>, BlockNumber), DatabaseError>
pub async fn select_nullifiers_by_prefix( &self, prefix_len: u32, nullifier_prefixes: Vec<u32>, block_range: RangeInclusive<BlockNumber>, ) -> Result<(Vec<NullifierInfo>, BlockNumber), DatabaseError>
Loads the nullifiers that match the prefixes from the DB.
Sourcepub async fn select_block_header_by_block_num(
&self,
maybe_block_number: Option<BlockNumber>,
) -> Result<Option<BlockHeader>, DatabaseError>
pub async fn select_block_header_by_block_num( &self, maybe_block_number: Option<BlockNumber>, ) -> Result<Option<BlockHeader>, DatabaseError>
Search for a BlockHeader from the database by its block_num.
When block_number is None, the latest block header is returned.
Sourcepub async fn select_block_header_and_signature_by_block_num(
&self,
block_number: BlockNumber,
) -> Result<Option<(BlockHeader, Signature)>, DatabaseError>
pub async fn select_block_header_and_signature_by_block_num( &self, block_number: BlockNumber, ) -> Result<Option<(BlockHeader, Signature)>, DatabaseError>
Search for a BlockHeader and its Signature from the database by its block_num.
Sourcepub async fn select_block_headers(
&self,
blocks: impl Iterator<Item = BlockNumber> + Send + 'static,
) -> Result<Vec<BlockHeader>, DatabaseError>
pub async fn select_block_headers( &self, blocks: impl Iterator<Item = BlockNumber> + Send + 'static, ) -> Result<Vec<BlockHeader>, DatabaseError>
Loads multiple block headers from the DB.
Sourcepub async fn select_all_block_header_commitments(
&self,
) -> Result<Vec<BlockHeaderCommitment>, DatabaseError>
pub async fn select_all_block_header_commitments( &self, ) -> Result<Vec<BlockHeaderCommitment>, DatabaseError>
Loads all the block headers from the DB.
Sourcepub async fn select_account_commitments_paged(
&self,
page_size: NonZeroUsize,
after_account_id: Option<AccountId>,
) -> Result<AccountCommitmentsPage, DatabaseError>
pub async fn select_account_commitments_paged( &self, page_size: NonZeroUsize, after_account_id: Option<AccountId>, ) -> Result<AccountCommitmentsPage, DatabaseError>
Returns a page of account commitments for tree rebuilding.
Sourcepub async fn select_public_account_ids_paged(
&self,
page_size: NonZeroUsize,
after_account_id: Option<AccountId>,
) -> Result<PublicAccountIdsPage, DatabaseError>
pub async fn select_public_account_ids_paged( &self, page_size: NonZeroUsize, after_account_id: Option<AccountId>, ) -> Result<PublicAccountIdsPage, DatabaseError>
Returns a page of public account IDs for forest rebuilding.
Sourcepub async fn select_public_account_state_roots_paged(
&self,
page_size: NonZeroUsize,
after_account_id: Option<AccountId>,
) -> Result<PublicAccountStateRootsPage, DatabaseError>
pub async fn select_public_account_state_roots_paged( &self, page_size: NonZeroUsize, after_account_id: Option<AccountId>, ) -> Result<PublicAccountStateRootsPage, DatabaseError>
Returns a page of public account state roots for forest consistency verification.
Sourcepub async fn select_account(
&self,
id: AccountId,
) -> Result<AccountInfo, DatabaseError>
pub async fn select_account( &self, id: AccountId, ) -> Result<AccountInfo, DatabaseError>
Loads public account details from the DB.
Sourcepub async fn select_network_accounts_subset(
&self,
account_ids: Vec<AccountId>,
) -> Result<HashSet<AccountId>, DatabaseError>
pub async fn select_network_accounts_subset( &self, account_ids: Vec<AccountId>, ) -> Result<HashSet<AccountId>, DatabaseError>
Returns the subset of the provided account IDs that classify as network accounts.
Sourcepub async fn select_account_code_by_commitment(
&self,
code_commitment: Word,
) -> Result<Option<Vec<u8>>, DatabaseError>
pub async fn select_account_code_by_commitment( &self, code_commitment: Word, ) -> Result<Option<Vec<u8>>, DatabaseError>
Queries the account code by its commitment hash.
Returns None if no code exists with that commitment.
Sourcepub async fn select_account_header_with_storage_header_at_block(
&self,
account_id: AccountId,
block_num: BlockNumber,
) -> Result<Option<(AccountHeader, AccountStorageHeader)>, DatabaseError>
pub async fn select_account_header_with_storage_header_at_block( &self, account_id: AccountId, block_num: BlockNumber, ) -> Result<Option<(AccountHeader, AccountStorageHeader)>, DatabaseError>
Queries the account header and storage header for a specific account at a block.
Returns both in a single query to avoid querying the database twice.
Returns None if the account doesn’t exist at that block.
pub async fn get_note_sync_multi( &self, block_range: RangeInclusive<BlockNumber>, note_tags: Arc<[u32]>, ) -> Result<Vec<NoteSyncUpdate>, NoteSyncError>
Sourcepub async fn select_notes_by_id(
&self,
note_ids: Vec<NoteId>,
) -> Result<Vec<NoteRecord>, DatabaseError>
pub async fn select_notes_by_id( &self, note_ids: Vec<NoteId>, ) -> Result<Vec<NoteRecord>, DatabaseError>
Loads all the miden_protocol::note::Notes matching a certain NoteId from the
database.
Sourcepub async fn select_existing_note_commitments(
&self,
note_commitments: Vec<Word>,
) -> Result<HashSet<Word>, DatabaseError>
pub async fn select_existing_note_commitments( &self, note_commitments: Vec<Word>, ) -> Result<HashSet<Word>, DatabaseError>
Returns all note commitments from the DB that match the provided ones.
Sourcepub async fn select_note_inclusion_proofs(
&self,
note_commitments: BTreeSet<Word>,
) -> Result<BTreeMap<NoteId, NoteInclusionProof>, DatabaseError>
pub async fn select_note_inclusion_proofs( &self, note_commitments: BTreeSet<Word>, ) -> Result<BTreeMap<NoteId, NoteInclusionProof>, DatabaseError>
Loads inclusion proofs for notes matching the given note commitments.
Sourcepub async fn apply_block(
&self,
allow_acquire: Sender<()>,
acquire_done: Receiver<()>,
signed_block: SignedBlock,
notes: Vec<(NoteRecord, Option<Nullifier>)>,
) -> Result<(), DatabaseError>
pub async fn apply_block( &self, allow_acquire: Sender<()>, acquire_done: Receiver<()>, signed_block: SignedBlock, notes: Vec<(NoteRecord, Option<Nullifier>)>, ) -> Result<(), DatabaseError>
Inserts the data of a new block into the DB.
allow_acquire and acquire_done are used to synchronize writes to the DB with writes to
the in-memory trees. Further details available on super::state::State::apply_block.
pub async fn get_account_vault_sync( &self, account_id: AccountId, block_range: RangeInclusive<BlockNumber>, ) -> Result<(BlockNumber, Vec<AccountVaultValue>), DatabaseError>
Sourcepub async fn select_note_script_by_root(
&self,
root: Word,
) -> Result<Option<NoteScript>, DatabaseError>
pub async fn select_note_script_by_root( &self, root: Word, ) -> Result<Option<NoteScript>, DatabaseError>
Returns the script for a note by its root.
Sourcepub async fn select_transactions_records(
&self,
account_ids: Vec<AccountId>,
block_range: RangeInclusive<BlockNumber>,
) -> Result<(BlockNumber, Vec<TransactionRecord>), DatabaseError>
pub async fn select_transactions_records( &self, account_ids: Vec<AccountId>, block_range: RangeInclusive<BlockNumber>, ) -> Result<(BlockNumber, Vec<TransactionRecord>), DatabaseError>
Returns the complete transaction records for the specified accounts within the specified block range, including state commitments and note IDs.
Note: This method is size-limited (~5MB) and may not return all matching transactions if the limit is exceeded. Transactions from partial blocks are excluded to maintain consistency.
Methods from Deref<Target = Db>§
Sourcepub async fn pinned_connection(&self) -> Result<PinnedConnection, DatabaseError>
pub async fn pinned_connection(&self) -> Result<PinnedConnection, DatabaseError>
Checks out a connection from the pool and pins it for the caller’s exclusive, long-lived
use. See PinnedConnection.
This removes one connection from the shared pool for the lifetime of the returned handle, so the pool must be sized to leave at least one connection for other users.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Db
impl !UnwindSafe for Db
impl Freeze for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more