pub struct BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,{ /* private fields */ }
Expand description
The block store.
Implementations§
Source§impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
Sourcepub fn open<S>(storage: S) -> Result<BlockStore<N, B>, Error>
pub fn open<S>(storage: S) -> Result<BlockStore<N, B>, Error>
Initializes the block store.
Sourcepub fn insert(&self, block: &Block<N>) -> Result<(), Error>
pub fn insert(&self, block: &Block<N>) -> Result<(), Error>
Stores the given block into storage.
Sourcepub fn remove_last_n(&self, n: u32) -> Result<(), Error>
pub fn remove_last_n(&self, n: u32) -> Result<(), Error>
Removes the last ‘n’ blocks from storage.
Sourcepub fn transaction_store(
&self,
) -> &TransactionStore<N, <B as BlockStorage<N>>::TransactionStorage>
pub fn transaction_store( &self, ) -> &TransactionStore<N, <B as BlockStorage<N>>::TransactionStorage>
Returns the transaction store.
Sourcepub fn transition_store(
&self,
) -> &TransitionStore<N, <B as BlockStorage<N>>::TransitionStorage>
pub fn transition_store( &self, ) -> &TransitionStore<N, <B as BlockStorage<N>>::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<(), Error>
pub fn finish_atomic(&self) -> Result<(), Error>
Finishes an atomic batch write operation.
Sourcepub fn storage_mode(&self) -> &StorageMode
pub fn storage_mode(&self) -> &StorageMode
Returns the storage mode.
Source§impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
Sourcepub fn find_block_height_from_state_root(
&self,
state_root: <N as Network>::StateRoot,
) -> Result<Option<u32>, Error>
pub fn find_block_height_from_state_root( &self, state_root: <N as Network>::StateRoot, ) -> Result<Option<u32>, Error>
Returns the block height that contains the given state root
.
Sourcepub fn find_block_hash(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<<N as Network>::BlockHash>, Error>
pub fn find_block_hash( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<<N as Network>::BlockHash>, Error>
Returns the block hash that contains the given transaction ID
.
Sourcepub fn find_block_height_from_puzzle_commitment(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<Option<u32>, Error>
pub fn find_block_height_from_puzzle_commitment( &self, puzzle_commitment: &PuzzleCommitment<N>, ) -> Result<Option<u32>, Error>
Returns the block height that contains the given puzzle commitment
.
Source§impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
Sourcepub fn current_state_root(&self) -> <N as Network>::StateRoot
pub fn current_state_root(&self) -> <N as Network>::StateRoot
Returns the current state root.
Sourcepub fn get_state_root(
&self,
block_height: u32,
) -> Result<Option<<N as Network>::StateRoot>, Error>
pub fn get_state_root( &self, block_height: u32, ) -> Result<Option<<N as Network>::StateRoot>, Error>
Returns the state root that contains the given block height
.
Sourcepub fn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
) -> Result<StatePath<N>, Error>
pub fn get_state_path_for_commitment( &self, commitment: &Field<N>, ) -> Result<StatePath<N>, Error>
Returns a state path for the given commitment
.
Sourcepub fn get_previous_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error>
pub fn get_previous_block_hash( &self, height: u32, ) -> Result<Option<<N as Network>::BlockHash>, Error>
Returns the previous block hash of the given block height
.
Sourcepub fn get_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error>
pub fn get_block_hash( &self, height: u32, ) -> Result<Option<<N as Network>::BlockHash>, Error>
Returns the block hash for the given block height
.
Sourcepub fn get_block_height(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<u32>, Error>
pub fn get_block_height( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<u32>, Error>
Returns the block height for the given block hash
.
Sourcepub fn get_block_header(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Header<N>>, Error>
pub fn get_block_header( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Header<N>>, Error>
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 as Network>::BlockHash,
) -> Result<Option<Ratifications<N>>, Error>
pub fn get_block_ratifications( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Ratifications<N>>, Error>
Returns the block ratifications for the given block hash
.
Sourcepub fn get_block_solutions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<CoinbaseSolution<N>>, Error>
pub fn get_block_solutions( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<CoinbaseSolution<N>>, Error>
Returns the block solutions for the given block hash
.
Sourcepub fn get_solution(
&self,
solution_id: &PuzzleCommitment<N>,
) -> Result<ProverSolution<N>, Error>
pub fn get_solution( &self, solution_id: &PuzzleCommitment<N>, ) -> Result<ProverSolution<N>, Error>
Returns the prover solution for the given solution ID.
Sourcepub fn get_block_transactions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Transactions<N>>, Error>
pub fn get_block_transactions( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Transactions<N>>, Error>
Returns the block transactions for the given block hash
.
Sourcepub fn get_block_aborted_transaction_ids(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Vec<<N as Network>::TransactionID>>, Error>
pub fn get_block_aborted_transaction_ids( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Vec<<N as Network>::TransactionID>>, Error>
Returns the block aborted transaction IDs for the given block hash
.
Sourcepub fn get_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error>
pub fn get_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<Transaction<N>>, Error>
Returns the transaction for the given transaction ID
.
Sourcepub fn get_confirmed_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<ConfirmedTransaction<N>>, Error>
pub fn get_confirmed_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<ConfirmedTransaction<N>>, Error>
Returns the confirmed transaction for the given transaction ID
.
Sourcepub fn get_unconfirmed_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error>
pub fn get_unconfirmed_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<Transaction<N>>, Error>
Returns the unconfirmed transaction for the given transaction ID
.
Sourcepub fn get_block(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Block<N>>, Error>
pub fn get_block( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Block<N>>, Error>
Returns the block for the given block hash
.
Sourcepub fn get_program(
&self,
program_id: &ProgramID<N>,
) -> Result<Option<ProgramCore<N, Instruction<N>, Command<N>>>, Error>
pub fn get_program( &self, program_id: &ProgramID<N>, ) -> Result<Option<ProgramCore<N, Instruction<N>, Command<N>>>, Error>
Returns the program for the given program ID
.
Sourcepub fn get_batch_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<Option<BatchCertificate<N>>, Error>
pub fn get_batch_certificate( &self, certificate_id: &Field<N>, ) -> Result<Option<BatchCertificate<N>>, Error>
Returns the batch certificate for the given certificate ID
.
Source§impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
Sourcepub fn contains_state_root(
&self,
state_root: &<N as Network>::StateRoot,
) -> Result<bool, Error>
pub fn contains_state_root( &self, state_root: &<N as Network>::StateRoot, ) -> Result<bool, Error>
Returns true
if the given state root exists.
Sourcepub fn contains_block_height(&self, height: u32) -> Result<bool, Error>
pub fn contains_block_height(&self, height: u32) -> Result<bool, Error>
Returns true
if the given block height exists.
Sourcepub fn contains_block_hash(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<bool, Error>
pub fn contains_block_hash( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<bool, Error>
Returns true
if the given block hash exists.
Sourcepub fn contains_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error>
pub fn contains_transaction_id( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<bool, Error>
Returns true
if the given transaction ID exists.
Sourcepub fn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error>
pub fn contains_rejected_or_aborted_transaction_id( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<bool, Error>
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, Error>
pub fn contains_rejected_deployment_or_execution_id( &self, rejected_id: &Field<N>, ) -> Result<bool, Error>
Returns true
if the given rejected deployment or execution ID.
Sourcepub fn contains_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<bool, Error>
pub fn contains_certificate( &self, certificate_id: &Field<N>, ) -> Result<bool, Error>
Returns true
if the given certificate ID exists.
Sourcepub fn contains_puzzle_commitment(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<bool, Error>
pub fn contains_puzzle_commitment( &self, puzzle_commitment: &PuzzleCommitment<N>, ) -> Result<bool, Error>
Returns true
if the given puzzle commitment exists.
Source§impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> BlockStore<N, B>where
N: Network,
B: BlockStorage<N>,
Sourcepub fn state_roots(
&self,
) -> impl Iterator<Item = Cow<'_, <N as Network>::StateRoot>>
pub fn state_roots( &self, ) -> impl Iterator<Item = Cow<'_, <N as Network>::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 hashes(&self) -> impl Iterator<Item = Cow<'_, <N as Network>::BlockHash>>
pub fn hashes(&self) -> impl Iterator<Item = Cow<'_, <N as Network>::BlockHash>>
Returns an iterator over the block hashes, for all blocks in self
.
Sourcepub fn puzzle_commitments(
&self,
) -> impl Iterator<Item = Cow<'_, PuzzleCommitment<N>>>
pub fn puzzle_commitments( &self, ) -> impl Iterator<Item = Cow<'_, PuzzleCommitment<N>>>
Returns an iterator over the puzzle commitments, for all blocks in self
.
Trait Implementations§
Source§impl<N, B> Clone for BlockStore<N, B>
impl<N, B> 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 moreSource§impl<N, B> From<&BlockStore<N, B>> for Query<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> From<&BlockStore<N, B>> for Query<N, B>where
N: Network,
B: BlockStorage<N>,
Source§fn from(block_store: &BlockStore<N, B>) -> Query<N, B>
fn from(block_store: &BlockStore<N, B>) -> Query<N, B>
Source§impl<N, B> From<BlockStore<N, B>> for Query<N, B>where
N: Network,
B: BlockStorage<N>,
impl<N, B> From<BlockStore<N, B>> for Query<N, B>where
N: Network,
B: BlockStorage<N>,
Source§fn from(block_store: BlockStore<N, B>) -> Query<N, B>
fn from(block_store: BlockStore<N, B>) -> Query<N, B>
Auto 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> 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 more