pub struct BlockStore<N: Network, B: BlockStorage<N>> { /* private fields */ }
Expand description
The block store.
Implementations§
Source§impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
Sourcepub fn open<S: Clone + Into<StorageMode>>(storage: S) -> Result<Self>
pub fn open<S: Clone + Into<StorageMode>>(storage: S) -> Result<Self>
Initializes the block store.
Sourcepub fn remove_last_n_from_tree_only(&self, n: u32) -> Result<()>
pub fn remove_last_n_from_tree_only(&self, n: u32) -> Result<()>
Reverts the Merkle tree to its shape before the insertion of the last ‘n’ blocks.
Sourcepub fn remove_last_n(&self, n: u32) -> Result<()>
pub fn remove_last_n(&self, n: u32) -> Result<()>
Removes the last ‘n’ blocks from storage.
Sourcepub fn transaction_store(&self) -> &TransactionStore<N, B::TransactionStorage>
pub fn transaction_store(&self) -> &TransactionStore<N, B::TransactionStorage>
Returns the transaction store.
Sourcepub fn transition_store(&self) -> &TransitionStore<N, B::TransitionStorage>
pub fn transition_store(&self) -> &TransitionStore<N, B::TransitionStorage>
Returns the transition store.
Sourcepub fn start_atomic(&self)
pub fn start_atomic(&self)
Starts an atomic batch write operation.
Sourcepub fn is_atomic_in_progress(&self) -> bool
pub fn is_atomic_in_progress(&self) -> bool
Checks if an atomic batch is in progress.
Sourcepub fn atomic_checkpoint(&self)
pub fn atomic_checkpoint(&self)
Checkpoints the atomic batch.
Sourcepub fn clear_latest_checkpoint(&self)
pub fn clear_latest_checkpoint(&self)
Clears the latest atomic batch checkpoint.
Sourcepub fn atomic_rewind(&self)
pub fn atomic_rewind(&self)
Rewinds the atomic batch to the previous checkpoint.
Sourcepub fn abort_atomic(&self)
pub fn abort_atomic(&self)
Aborts an atomic batch write operation.
Sourcepub fn finish_atomic(&self) -> Result<()>
pub fn finish_atomic(&self) -> Result<()>
Finishes an atomic batch write operation.
Sourcepub fn storage_mode(&self) -> &StorageMode
pub fn storage_mode(&self) -> &StorageMode
Returns the storage mode.
Sourcepub fn pause_atomic_writes(&self) -> Result<()>
pub fn pause_atomic_writes(&self) -> Result<()>
Pauses atomic writes.
Sourcepub fn unpause_atomic_writes<const DISCARD_BATCH: bool>(&self) -> Result<()>
pub fn unpause_atomic_writes<const DISCARD_BATCH: bool>(&self) -> Result<()>
Unpauses atomic writes.
Source§impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
Sourcepub fn find_block_height_from_state_root(
&self,
state_root: N::StateRoot,
) -> Result<Option<u32>>
pub fn find_block_height_from_state_root( &self, state_root: N::StateRoot, ) -> Result<Option<u32>>
Returns the block height that contains the given state root
.
Sourcepub fn find_block_hash(
&self,
transaction_id: &N::TransactionID,
) -> Result<Option<N::BlockHash>>
pub fn find_block_hash( &self, transaction_id: &N::TransactionID, ) -> Result<Option<N::BlockHash>>
Returns the block hash that contains the given transaction ID
.
Sourcepub fn find_block_height_from_solution_id(
&self,
solution_id: &SolutionID<N>,
) -> Result<Option<u32>>
pub fn find_block_height_from_solution_id( &self, solution_id: &SolutionID<N>, ) -> Result<Option<u32>>
Returns the block height that contains the given solution ID
.
Source§impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
Sourcepub fn current_state_root(&self) -> N::StateRoot
pub fn current_state_root(&self) -> N::StateRoot
Returns the current state root.
Sourcepub fn current_block_height(&self) -> u32
pub fn current_block_height(&self) -> u32
Returns the current block height.
Sourcepub fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
pub fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
Returns the state root that contains the given block height
.
Sourcepub fn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
) -> Result<StatePath<N>>
pub fn get_state_path_for_commitment( &self, commitment: &Field<N>, ) -> Result<StatePath<N>>
Returns a state path for the given commitment
.
Sourcepub fn get_previous_block_hash(
&self,
height: u32,
) -> Result<Option<N::BlockHash>>
pub fn get_previous_block_hash( &self, height: u32, ) -> Result<Option<N::BlockHash>>
Returns the previous block hash of the given block height
.
Sourcepub fn get_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
pub fn get_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
Returns the block hash for the given block height
.
Sourcepub fn get_block_height(&self, block_hash: &N::BlockHash) -> Result<Option<u32>>
pub fn get_block_height(&self, block_hash: &N::BlockHash) -> Result<Option<u32>>
Returns the block height for the given block hash
.
Sourcepub fn get_block_header(
&self,
block_hash: &N::BlockHash,
) -> Result<Option<Header<N>>>
pub fn get_block_header( &self, block_hash: &N::BlockHash, ) -> Result<Option<Header<N>>>
Returns the block header for the given block hash
.
Returns the block authority for the given block hash
.
Sourcepub fn get_block_ratifications(
&self,
block_hash: &N::BlockHash,
) -> Result<Option<Ratifications<N>>>
pub fn get_block_ratifications( &self, block_hash: &N::BlockHash, ) -> Result<Option<Ratifications<N>>>
Returns the block ratifications for the given block hash
.
Sourcepub fn get_block_solutions(
&self,
block_hash: &N::BlockHash,
) -> Result<Solutions<N>>
pub fn get_block_solutions( &self, block_hash: &N::BlockHash, ) -> Result<Solutions<N>>
Returns the block solutions for the given block hash
.
Sourcepub fn get_solution(&self, solution_id: &SolutionID<N>) -> Result<Solution<N>>
pub fn get_solution(&self, solution_id: &SolutionID<N>) -> Result<Solution<N>>
Returns the prover solution for the given solution ID.
Sourcepub fn get_block_transactions(
&self,
block_hash: &N::BlockHash,
) -> Result<Option<Transactions<N>>>
pub fn get_block_transactions( &self, block_hash: &N::BlockHash, ) -> Result<Option<Transactions<N>>>
Returns the block transactions for the given block hash
.
Sourcepub fn get_block_aborted_transaction_ids(
&self,
block_hash: &N::BlockHash,
) -> Result<Option<Vec<N::TransactionID>>>
pub fn get_block_aborted_transaction_ids( &self, block_hash: &N::BlockHash, ) -> Result<Option<Vec<N::TransactionID>>>
Returns the block aborted transaction IDs for the given block hash
.
Sourcepub fn get_transaction(
&self,
transaction_id: &N::TransactionID,
) -> Result<Option<Transaction<N>>>
pub fn get_transaction( &self, transaction_id: &N::TransactionID, ) -> Result<Option<Transaction<N>>>
Returns the transaction for the given transaction ID
.
Sourcepub fn get_confirmed_transaction(
&self,
transaction_id: &N::TransactionID,
) -> Result<Option<ConfirmedTransaction<N>>>
pub fn get_confirmed_transaction( &self, transaction_id: &N::TransactionID, ) -> Result<Option<ConfirmedTransaction<N>>>
Returns the confirmed transaction for the given transaction ID
.
Sourcepub fn get_unconfirmed_transaction(
&self,
transaction_id: &N::TransactionID,
) -> Result<Option<Transaction<N>>>
pub fn get_unconfirmed_transaction( &self, transaction_id: &N::TransactionID, ) -> Result<Option<Transaction<N>>>
Returns the unconfirmed transaction for the given transaction ID
.
Sourcepub fn get_block(&self, block_hash: &N::BlockHash) -> Result<Option<Block<N>>>
pub fn get_block(&self, block_hash: &N::BlockHash) -> Result<Option<Block<N>>>
Returns the block for the given block hash
.
Sourcepub fn get_program(
&self,
program_id: &ProgramID<N>,
) -> Result<Option<Program<N>>>
pub fn get_program( &self, program_id: &ProgramID<N>, ) -> Result<Option<Program<N>>>
Returns the program for the given program ID
.
Sourcepub fn get_batch_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<Option<BatchCertificate<N>>>
pub fn get_batch_certificate( &self, certificate_id: &Field<N>, ) -> Result<Option<BatchCertificate<N>>>
Returns the batch certificate for the given certificate ID
.
Source§impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
Sourcepub fn contains_state_root(&self, state_root: &N::StateRoot) -> Result<bool>
pub fn contains_state_root(&self, state_root: &N::StateRoot) -> Result<bool>
Returns true
if the given state root exists.
Sourcepub fn contains_block_height(&self, height: u32) -> Result<bool>
pub fn contains_block_height(&self, height: u32) -> Result<bool>
Returns true
if the given block height exists.
Sourcepub fn contains_block_hash(&self, block_hash: &N::BlockHash) -> Result<bool>
pub fn contains_block_hash(&self, block_hash: &N::BlockHash) -> Result<bool>
Returns true
if the given block hash exists.
Sourcepub fn contains_transaction_id(
&self,
transaction_id: &N::TransactionID,
) -> Result<bool>
pub fn contains_transaction_id( &self, transaction_id: &N::TransactionID, ) -> Result<bool>
Returns true
if the given transaction ID exists.
Sourcepub fn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &N::TransactionID,
) -> Result<bool>
pub fn contains_rejected_or_aborted_transaction_id( &self, transaction_id: &N::TransactionID, ) -> Result<bool>
Returns true
if the given rejected transaction ID or aborted transaction ID exists.
Sourcepub fn contains_rejected_deployment_or_execution_id(
&self,
rejected_id: &Field<N>,
) -> Result<bool>
pub fn contains_rejected_deployment_or_execution_id( &self, rejected_id: &Field<N>, ) -> Result<bool>
Returns true
if the given rejected deployment or execution ID.
Sourcepub fn contains_certificate(&self, certificate_id: &Field<N>) -> Result<bool>
pub fn contains_certificate(&self, certificate_id: &Field<N>) -> Result<bool>
Returns true
if the given certificate ID exists.
Sourcepub fn contains_solution_id(&self, solution_id: &SolutionID<N>) -> Result<bool>
pub fn contains_solution_id(&self, solution_id: &SolutionID<N>) -> Result<bool>
Returns true
if the given solution ID exists.
Source§impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
impl<N: Network, B: BlockStorage<N>> BlockStore<N, B>
Sourcepub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>>
pub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>>
Returns an iterator over the state roots, for all blocks in self
.
Sourcepub fn heights(&self) -> impl '_ + Iterator<Item = Cow<'_, u32>>
pub fn heights(&self) -> impl '_ + Iterator<Item = Cow<'_, u32>>
Returns an iterator over the block heights, for all blocks in self
.
Sourcepub fn max_height(&self) -> Option<u32>
pub fn max_height(&self) -> Option<u32>
Returns the height of the latest block in the storage.
Sourcepub fn hashes(&self) -> impl '_ + Iterator<Item = Cow<'_, N::BlockHash>>
pub fn hashes(&self) -> impl '_ + Iterator<Item = Cow<'_, N::BlockHash>>
Returns an iterator over the block hashes, for all blocks in self
.
Sourcepub fn solution_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, SolutionID<N>>>
pub fn solution_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, SolutionID<N>>>
Returns an iterator over the solution IDs, for all blocks in self
.
Trait Implementations§
Source§impl<N: Clone + Network, B: Clone + BlockStorage<N>> Clone for BlockStore<N, B>
impl<N: Clone + Network, B: Clone + BlockStorage<N>> Clone for BlockStore<N, B>
Source§fn clone(&self) -> BlockStore<N, B>
fn clone(&self) -> BlockStore<N, B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<N, B> Freeze for BlockStore<N, B>where
B: Freeze,
impl<N, B> !RefUnwindSafe for BlockStore<N, B>
impl<N, B> Send for BlockStore<N, B>
impl<N, B> Sync for BlockStore<N, B>
impl<N, B> Unpin for BlockStore<N, B>where
B: Unpin,
impl<N, B> !UnwindSafe for BlockStore<N, B>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more