Struct BlockStore

Source
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>,

Source

pub fn open<S>(storage: S) -> Result<BlockStore<N, B>, Error>
where S: Clone + Into<StorageMode>,

Initializes the block store.

Source

pub fn insert(&self, block: &Block<N>) -> Result<(), Error>

Stores the given block into storage.

Source

pub fn remove_last_n(&self, n: u32) -> Result<(), Error>

Removes the last ‘n’ blocks from storage.

Source

pub fn transaction_store( &self, ) -> &TransactionStore<N, <B as BlockStorage<N>>::TransactionStorage>

Returns the transaction store.

Source

pub fn transition_store( &self, ) -> &TransitionStore<N, <B as BlockStorage<N>>::TransitionStorage>

Returns the transition store.

Source

pub fn start_atomic(&self)

Starts an atomic batch write operation.

Source

pub fn is_atomic_in_progress(&self) -> bool

Checks if an atomic batch is in progress.

Source

pub fn atomic_checkpoint(&self)

Checkpoints the atomic batch.

Source

pub fn clear_latest_checkpoint(&self)

Clears the latest atomic batch checkpoint.

Source

pub fn atomic_rewind(&self)

Rewinds the atomic batch to the previous checkpoint.

Source

pub fn abort_atomic(&self)

Aborts an atomic batch write operation.

Source

pub fn finish_atomic(&self) -> Result<(), Error>

Finishes an atomic batch write operation.

Source

pub fn storage_mode(&self) -> &StorageMode

Returns the storage mode.

Source§

impl<N, B> BlockStore<N, B>
where N: Network, B: BlockStorage<N>,

Source

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.

Source

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.

Source

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>,

Source

pub fn current_state_root(&self) -> <N as Network>::StateRoot

Returns the current state root.

Source

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.

Source

pub fn get_state_path_for_commitment( &self, commitment: &Field<N>, ) -> Result<StatePath<N>, Error>

Returns a state path for the given commitment.

Source

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.

Source

pub fn get_block_hash( &self, height: u32, ) -> Result<Option<<N as Network>::BlockHash>, Error>

Returns the block hash for the given block height.

Source

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.

Source

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.

Source

pub fn get_block_authority( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Authority<N>>, Error>

Returns the block authority for the given block hash.

Source

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.

Source

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.

Source

pub fn get_solution( &self, solution_id: &PuzzleCommitment<N>, ) -> Result<ProverSolution<N>, Error>

Returns the prover solution for the given solution ID.

Source

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.

Source

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.

Source

pub fn get_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<Transaction<N>>, Error>

Returns the transaction for the given transaction ID.

Source

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.

Source

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.

Source

pub fn get_block( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<Block<N>>, Error>

Returns the block for the given block hash.

Source

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.

Source

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>,

Source

pub fn contains_state_root( &self, state_root: &<N as Network>::StateRoot, ) -> Result<bool, Error>

Returns true if the given state root exists.

Source

pub fn contains_block_height(&self, height: u32) -> Result<bool, Error>

Returns true if the given block height exists.

Source

pub fn contains_block_hash( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<bool, Error>

Returns true if the given block hash exists.

Source

pub fn contains_transaction_id( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<bool, Error>

Returns true if the given transaction ID exists.

Source

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.

Source

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.

Source

pub fn contains_certificate( &self, certificate_id: &Field<N>, ) -> Result<bool, Error>

Returns true if the given certificate ID exists.

Source

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>,

Source

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.

Source

pub fn heights(&self) -> impl Iterator<Item = Cow<'_, u32>>

Returns an iterator over the block heights, for all blocks in self.

Source

pub fn hashes(&self) -> impl Iterator<Item = Cow<'_, <N as Network>::BlockHash>>

Returns an iterator over the block hashes, for all blocks in self.

Source

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>
where N: Clone + Network, B: Clone + BlockStorage<N>,

Source§

fn clone(&self) -> BlockStore<N, B>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>

Converts to this type from the input type.
Source§

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>

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T