pub struct Db { /* private fields */ }Expand description
The Store’s database.
Every write serializes on the single framework writer connection. Every read runs on the framework reader pool.
Implementations§
Source§impl Db
impl Db
Sourcepub async fn bootstrap(
database_filepath: PathBuf,
genesis: GenesisBlock,
) -> Result<()>
pub async 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 async fn select_protocol_config_by_commitment(
&self,
commitment: Word,
) -> Result<Option<ProtocolConfig>, DatabaseError>
pub async fn select_protocol_config_by_commitment( &self, commitment: Word, ) -> Result<Option<ProtocolConfig>, DatabaseError>
Selects a protocol configuration by its commitment.
Sourcepub async fn select_protocol_config_commitment_at(
&self,
block_number: ScopedBlockNum,
) -> Result<Option<Word>, DatabaseError>
pub async fn select_protocol_config_commitment_at( &self, block_number: ScopedBlockNum, ) -> Result<Option<Word>, DatabaseError>
Selects the configuration commitment active at the specified block.
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: ScopedBlockRange,
) -> Result<(Vec<NullifierInfo>, BlockNumber), DatabaseError>
pub async fn select_nullifiers_by_prefix( &self, prefix_len: u32, nullifier_prefixes: Vec<u32>, block_range: ScopedBlockRange, ) -> 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<ScopedBlockNum>,
) -> Result<Option<BlockHeader>, DatabaseError>
pub async fn select_block_header_by_block_num( &self, maybe_block_number: Option<ScopedBlockNum>, ) -> 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_signatures_by_block_num(
&self,
block_number: ScopedBlockNum,
) -> Result<Option<(BlockHeader, BlockSignatures)>, DatabaseError>
pub async fn select_block_header_and_signatures_by_block_num( &self, block_number: ScopedBlockNum, ) -> Result<Option<(BlockHeader, BlockSignatures)>, DatabaseError>
Search for a BlockHeader and its BlockSignatures from the database by its
block_num.
Sourcepub async fn select_block_headers(
&self,
blocks: impl Iterator<Item = ScopedBlockNum> + Send + 'static,
) -> Result<Vec<BlockHeader>, DatabaseError>
pub async fn select_block_headers( &self, blocks: impl Iterator<Item = ScopedBlockNum> + 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 filter_network_accounts(
&self,
account_ids: Vec<AccountId>,
) -> Result<HashSet<AccountId>, DatabaseError>
pub async fn filter_network_accounts( &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<AccountCode>, DatabaseError>
pub async fn select_account_code_by_commitment( &self, code_commitment: Word, ) -> Result<Option<AccountCode>, 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: ScopedBlockNum,
) -> Result<Option<(AccountHeader, AccountStorageHeader)>, DatabaseError>
pub async fn select_account_header_with_storage_header_at_block( &self, account_id: AccountId, block_num: ScopedBlockNum, ) -> 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: ScopedBlockRange, 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_ids(
&self,
note_ids: Vec<NoteId>,
up_to_block: ScopedBlockNum,
) -> Result<HashSet<NoteId>, DatabaseError>
pub async fn select_existing_note_ids( &self, note_ids: Vec<NoteId>, up_to_block: ScopedBlockNum, ) -> Result<HashSet<NoteId>, DatabaseError>
Returns the requested note IDs that the database contains at or before up_to_block.
Sourcepub async fn select_note_inclusion_proofs(
&self,
note_commitments: BTreeSet<Word>,
up_to_block: ScopedBlockNum,
) -> Result<BTreeMap<NoteId, NoteInclusionProof>, DatabaseError>
pub async fn select_note_inclusion_proofs( &self, note_commitments: BTreeSet<Word>, up_to_block: ScopedBlockNum, ) -> Result<BTreeMap<NoteId, NoteInclusionProof>, DatabaseError>
Loads inclusion proofs for notes matching the given note commitments that were committed at
or before up_to_block.
Sourcepub async fn select_vault_at_block(
&self,
account_id: AccountId,
block_num: ScopedBlockNum,
) -> Result<Vec<Asset>, DatabaseError>
pub async fn select_vault_at_block( &self, account_id: AccountId, block_num: ScopedBlockNum, ) -> Result<Vec<Asset>, DatabaseError>
Reconstructs the account vault from the database for a specific account at a block.
Used as fallback when the AccountStateForest vault-key cache misses (historical or evicted
queries). Returns the latest asset for each vault key at or before block_num.
pub async fn get_account_vault_sync( &self, account_id: AccountId, block_range: ScopedBlockRange, ) -> 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: ScopedBlockRange,
) -> Result<(BlockNumber, Vec<TransactionRecord>), DatabaseError>
pub async fn select_transactions_records( &self, account_ids: Vec<AccountId>, block_range: ScopedBlockRange, ) -> 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.
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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<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