pub trait BlockStorage<N>:
'static
+ Clone
+ Send
+ Syncwhere
N: Network,{
Show 68 associated items
type StateRootMap: for<'a> Map<'a, u32, <N as Network>::StateRoot>;
type ReverseStateRootMap: for<'a> Map<'a, <N as Network>::StateRoot, u32>;
type IDMap: for<'a> Map<'a, u32, <N as Network>::BlockHash>;
type ReverseIDMap: for<'a> Map<'a, <N as Network>::BlockHash, u32>;
type HeaderMap: for<'a> Map<'a, <N as Network>::BlockHash, Header<N>>;
type AuthorityMap: for<'a> Map<'a, <N as Network>::BlockHash, Authority<N>>;
type CertificateMap: for<'a> Map<'a, Field<N>, (u32, u64)>;
type RatificationsMap: for<'a> Map<'a, <N as Network>::BlockHash, Ratifications<N>>;
type SolutionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Option<CoinbaseSolution<N>>>;
type PuzzleCommitmentsMap: for<'a> Map<'a, PuzzleCommitment<N>, u32>;
type TransactionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>;
type AbortedTransactionIDsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>;
type RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, <N as Network>::TransactionID, <N as Network>::BlockHash>;
type ConfirmedTransactionsMap: for<'a> Map<'a, <N as Network>::TransactionID, (<N as Network>::BlockHash, ConfirmedTxType, Vec<u8>)>;
type RejectedDeploymentOrExecutionMap: for<'a> Map<'a, Field<N>, Rejected<N>>;
type TransactionStorage: TransactionStorage<N, TransitionStorage = Self::TransitionStorage>;
type TransitionStorage: TransitionStorage<N>;
// Required methods
fn open(dev: Option<u16>) -> Result<Self, Error>;
fn state_root_map(&self) -> &Self::StateRootMap;
fn reverse_state_root_map(&self) -> &Self::ReverseStateRootMap;
fn id_map(&self) -> &Self::IDMap;
fn reverse_id_map(&self) -> &Self::ReverseIDMap;
fn header_map(&self) -> &Self::HeaderMap;
fn authority_map(&self) -> &Self::AuthorityMap;
fn certificate_map(&self) -> &Self::CertificateMap;
fn ratifications_map(&self) -> &Self::RatificationsMap;
fn solutions_map(&self) -> &Self::SolutionsMap;
fn puzzle_commitments_map(&self) -> &Self::PuzzleCommitmentsMap;
fn transactions_map(&self) -> &Self::TransactionsMap;
fn aborted_transaction_ids_map(&self) -> &Self::AbortedTransactionIDsMap;
fn rejected_or_aborted_transaction_id_map(
&self,
) -> &Self::RejectedOrAbortedTransactionIDMap;
fn confirmed_transactions_map(&self) -> &Self::ConfirmedTransactionsMap;
fn rejected_deployment_or_execution_map(
&self,
) -> &Self::RejectedDeploymentOrExecutionMap;
fn transaction_store(
&self,
) -> &TransactionStore<N, Self::TransactionStorage>;
// Provided methods
fn transition_store(&self) -> &TransitionStore<N, Self::TransitionStorage> { ... }
fn dev(&self) -> Option<u16> { ... }
fn start_atomic(&self) { ... }
fn is_atomic_in_progress(&self) -> bool { ... }
fn atomic_checkpoint(&self) { ... }
fn clear_latest_checkpoint(&self) { ... }
fn atomic_rewind(&self) { ... }
fn abort_atomic(&self) { ... }
fn finish_atomic(&self) -> Result<(), Error> { ... }
fn insert(
&self,
state_root: <N as Network>::StateRoot,
block: &Block<N>,
) -> Result<(), Error> { ... }
fn remove(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<(), Error> { ... }
fn contains_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error> { ... }
fn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error> { ... }
fn contains_rejected_deployment_or_execution_id(
&self,
rejected_id: &Field<N>,
) -> Result<bool, Error> { ... }
fn find_block_height_from_state_root(
&self,
state_root: <N as Network>::StateRoot,
) -> Result<Option<u32>, Error> { ... }
fn find_block_hash(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<<N as Network>::BlockHash>, Error> { ... }
fn find_block_height_from_puzzle_commitment(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<Option<u32>, Error> { ... }
fn get_state_root(
&self,
block_height: u32,
) -> Result<Option<<N as Network>::StateRoot>, Error> { ... }
fn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
block_tree: &MerkleTree<N, BHP<N, 8, 54>, BHP<N, 6, 43>, snarkvm_console_program::::state_path::configuration::BlockTree::{constant#0}>,
) -> Result<StatePath<N>, Error> { ... }
fn get_previous_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error> { ... }
fn get_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error> { ... }
fn get_block_height(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<u32>, Error> { ... }
fn get_block_header(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Header<N>>, Error> { ... }
fn get_block_authority(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Authority<N>>, Error> { ... }
fn get_batch_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<Option<BatchCertificate<N>>, Error> { ... }
fn get_block_ratifications(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Ratifications<N>>, Error> { ... }
fn get_block_solutions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<CoinbaseSolution<N>>, Error> { ... }
fn get_solution(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<ProverSolution<N>, Error> { ... }
fn get_block_transactions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Transactions<N>>, Error> { ... }
fn get_block_aborted_transaction_ids(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Vec<<N as Network>::TransactionID>>, Error> { ... }
fn get_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error> { ... }
fn get_confirmed_transaction(
&self,
transaction_id: <N as Network>::TransactionID,
) -> Result<Option<ConfirmedTransaction<N>>, Error> { ... }
fn get_unconfirmed_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error> { ... }
fn get_block(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Block<N>>, Error> { ... }
}Expand description
A trait for block storage.
Required Associated Types§
Sourcetype StateRootMap: for<'a> Map<'a, u32, <N as Network>::StateRoot>
type StateRootMap: for<'a> Map<'a, u32, <N as Network>::StateRoot>
The mapping of block height to state root.
Sourcetype ReverseStateRootMap: for<'a> Map<'a, <N as Network>::StateRoot, u32>
type ReverseStateRootMap: for<'a> Map<'a, <N as Network>::StateRoot, u32>
The mapping of state root to block height.
Sourcetype IDMap: for<'a> Map<'a, u32, <N as Network>::BlockHash>
type IDMap: for<'a> Map<'a, u32, <N as Network>::BlockHash>
The mapping of block height to block hash.
Sourcetype ReverseIDMap: for<'a> Map<'a, <N as Network>::BlockHash, u32>
type ReverseIDMap: for<'a> Map<'a, <N as Network>::BlockHash, u32>
The mapping of block hash to block height.
Sourcetype HeaderMap: for<'a> Map<'a, <N as Network>::BlockHash, Header<N>>
type HeaderMap: for<'a> Map<'a, <N as Network>::BlockHash, Header<N>>
The mapping of block hash to block header.
Sourcetype AuthorityMap: for<'a> Map<'a, <N as Network>::BlockHash, Authority<N>>
type AuthorityMap: for<'a> Map<'a, <N as Network>::BlockHash, Authority<N>>
The mapping of block hash to block authority.
Sourcetype CertificateMap: for<'a> Map<'a, Field<N>, (u32, u64)>
type CertificateMap: for<'a> Map<'a, Field<N>, (u32, u64)>
The mapping of certificate ID to (block height, round height).
Sourcetype RatificationsMap: for<'a> Map<'a, <N as Network>::BlockHash, Ratifications<N>>
type RatificationsMap: for<'a> Map<'a, <N as Network>::BlockHash, Ratifications<N>>
The mapping of block hash to block ratifications.
Sourcetype SolutionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Option<CoinbaseSolution<N>>>
type SolutionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Option<CoinbaseSolution<N>>>
The mapping of block hash to block solutions.
Sourcetype PuzzleCommitmentsMap: for<'a> Map<'a, PuzzleCommitment<N>, u32>
type PuzzleCommitmentsMap: for<'a> Map<'a, PuzzleCommitment<N>, u32>
The mapping of puzzle commitment to block height.
Sourcetype TransactionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>
type TransactionsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>
The mapping of block hash to [transaction ID].
Sourcetype AbortedTransactionIDsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>
type AbortedTransactionIDsMap: for<'a> Map<'a, <N as Network>::BlockHash, Vec<<N as Network>::TransactionID>>
The mapping of block hash to [aborted transaction ID].
Sourcetype RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, <N as Network>::TransactionID, <N as Network>::BlockHash>
type RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, <N as Network>::TransactionID, <N as Network>::BlockHash>
The mapping of rejected or aborted transaction ID to block hash.
Sourcetype ConfirmedTransactionsMap: for<'a> Map<'a, <N as Network>::TransactionID, (<N as Network>::BlockHash, ConfirmedTxType, Vec<u8>)>
type ConfirmedTransactionsMap: for<'a> Map<'a, <N as Network>::TransactionID, (<N as Network>::BlockHash, ConfirmedTxType, Vec<u8>)>
The mapping of transaction ID to (block hash, confirmed tx type, confirmed blob).
TODO (howardwu): For mainnet - With recent DB changes, to prevent breaking compatibility,
include rejected (d or e) ID into ConfirmedTxType, and change from Vec<u8> to Vec<FinalizeOps>.
Sourcetype RejectedDeploymentOrExecutionMap: for<'a> Map<'a, Field<N>, Rejected<N>>
type RejectedDeploymentOrExecutionMap: for<'a> Map<'a, Field<N>, Rejected<N>>
The rejected deployment or execution map.
Sourcetype TransactionStorage: TransactionStorage<N, TransitionStorage = Self::TransitionStorage>
type TransactionStorage: TransactionStorage<N, TransitionStorage = Self::TransitionStorage>
The transaction storage.
Sourcetype TransitionStorage: TransitionStorage<N>
type TransitionStorage: TransitionStorage<N>
The transition storage.
Required Methods§
Sourcefn state_root_map(&self) -> &Self::StateRootMap
fn state_root_map(&self) -> &Self::StateRootMap
Returns the state root map.
Sourcefn reverse_state_root_map(&self) -> &Self::ReverseStateRootMap
fn reverse_state_root_map(&self) -> &Self::ReverseStateRootMap
Returns the reverse state root map.
Sourcefn reverse_id_map(&self) -> &Self::ReverseIDMap
fn reverse_id_map(&self) -> &Self::ReverseIDMap
Returns the reverse ID map.
Sourcefn header_map(&self) -> &Self::HeaderMap
fn header_map(&self) -> &Self::HeaderMap
Returns the header map.
Returns the authority map.
Sourcefn certificate_map(&self) -> &Self::CertificateMap
fn certificate_map(&self) -> &Self::CertificateMap
Returns the certificate map.
Sourcefn ratifications_map(&self) -> &Self::RatificationsMap
fn ratifications_map(&self) -> &Self::RatificationsMap
Returns the ratifications map.
Sourcefn solutions_map(&self) -> &Self::SolutionsMap
fn solutions_map(&self) -> &Self::SolutionsMap
Returns the solutions map.
Sourcefn puzzle_commitments_map(&self) -> &Self::PuzzleCommitmentsMap
fn puzzle_commitments_map(&self) -> &Self::PuzzleCommitmentsMap
Returns the puzzle commitments map.
Sourcefn transactions_map(&self) -> &Self::TransactionsMap
fn transactions_map(&self) -> &Self::TransactionsMap
Returns the accepted transactions map.
Sourcefn aborted_transaction_ids_map(&self) -> &Self::AbortedTransactionIDsMap
fn aborted_transaction_ids_map(&self) -> &Self::AbortedTransactionIDsMap
Returns the aborted transaction IDs map.
Sourcefn rejected_or_aborted_transaction_id_map(
&self,
) -> &Self::RejectedOrAbortedTransactionIDMap
fn rejected_or_aborted_transaction_id_map( &self, ) -> &Self::RejectedOrAbortedTransactionIDMap
Returns the rejected or aborted transaction ID map.
Sourcefn confirmed_transactions_map(&self) -> &Self::ConfirmedTransactionsMap
fn confirmed_transactions_map(&self) -> &Self::ConfirmedTransactionsMap
Returns the confirmed transactions map.
Sourcefn rejected_deployment_or_execution_map(
&self,
) -> &Self::RejectedDeploymentOrExecutionMap
fn rejected_deployment_or_execution_map( &self, ) -> &Self::RejectedDeploymentOrExecutionMap
Returns the rejected deployment or execution map.
Sourcefn transaction_store(&self) -> &TransactionStore<N, Self::TransactionStorage>
fn transaction_store(&self) -> &TransactionStore<N, Self::TransactionStorage>
Returns the transaction store.
Provided Methods§
Sourcefn transition_store(&self) -> &TransitionStore<N, Self::TransitionStorage>
fn transition_store(&self) -> &TransitionStore<N, Self::TransitionStorage>
Returns the transition store.
Sourcefn start_atomic(&self)
fn start_atomic(&self)
Starts an atomic batch write operation.
Sourcefn is_atomic_in_progress(&self) -> bool
fn is_atomic_in_progress(&self) -> bool
Checks if an atomic batch is in progress.
Sourcefn atomic_checkpoint(&self)
fn atomic_checkpoint(&self)
Checkpoints the atomic batch.
Sourcefn clear_latest_checkpoint(&self)
fn clear_latest_checkpoint(&self)
Clears the latest atomic batch checkpoint.
Sourcefn atomic_rewind(&self)
fn atomic_rewind(&self)
Rewinds the atomic batch to the previous checkpoint.
Sourcefn abort_atomic(&self)
fn abort_atomic(&self)
Aborts an atomic batch write operation.
Sourcefn finish_atomic(&self) -> Result<(), Error>
fn finish_atomic(&self) -> Result<(), Error>
Finishes an atomic batch write operation.
Sourcefn insert(
&self,
state_root: <N as Network>::StateRoot,
block: &Block<N>,
) -> Result<(), Error>
fn insert( &self, state_root: <N as Network>::StateRoot, block: &Block<N>, ) -> Result<(), Error>
Stores the given (state root, block) pair into storage.
Sourcefn remove(&self, block_hash: &<N as Network>::BlockHash) -> Result<(), Error>
fn remove(&self, block_hash: &<N as Network>::BlockHash) -> Result<(), Error>
Removes the block for the given block hash.
Sourcefn contains_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error>
fn contains_transaction_id( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<bool, Error>
Returns true if the given transaction ID exists.
Sourcefn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<bool, Error>
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.
Sourcefn contains_rejected_deployment_or_execution_id(
&self,
rejected_id: &Field<N>,
) -> Result<bool, Error>
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.
Sourcefn find_block_height_from_state_root(
&self,
state_root: <N as Network>::StateRoot,
) -> Result<Option<u32>, Error>
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.
Sourcefn find_block_hash(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<<N as Network>::BlockHash>, Error>
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.
Sourcefn find_block_height_from_puzzle_commitment(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<Option<u32>, Error>
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.
Sourcefn get_state_root(
&self,
block_height: u32,
) -> Result<Option<<N as Network>::StateRoot>, Error>
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.
Sourcefn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
block_tree: &MerkleTree<N, BHP<N, 8, 54>, BHP<N, 6, 43>, snarkvm_console_program::::state_path::configuration::BlockTree::{constant#0}>,
) -> Result<StatePath<N>, Error>
fn get_state_path_for_commitment( &self, commitment: &Field<N>, block_tree: &MerkleTree<N, BHP<N, 8, 54>, BHP<N, 6, 43>, snarkvm_console_program::::state_path::configuration::BlockTree::{constant#0}>, ) -> Result<StatePath<N>, Error>
Returns a state path for the given commitment.
Sourcefn get_previous_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error>
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.
Sourcefn get_block_hash(
&self,
height: u32,
) -> Result<Option<<N as Network>::BlockHash>, Error>
fn get_block_hash( &self, height: u32, ) -> Result<Option<<N as Network>::BlockHash>, Error>
Returns the block hash for the given block height.
Sourcefn get_block_height(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<u32>, Error>
fn get_block_height( &self, block_hash: &<N as Network>::BlockHash, ) -> Result<Option<u32>, Error>
Returns the block height for the given block hash.
Sourcefn get_block_header(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Header<N>>, Error>
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.
Sourcefn get_batch_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<Option<BatchCertificate<N>>, Error>
fn get_batch_certificate( &self, certificate_id: &Field<N>, ) -> Result<Option<BatchCertificate<N>>, Error>
Returns the batch certificate for the given certificate ID.
Sourcefn get_block_ratifications(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Ratifications<N>>, Error>
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.
Sourcefn get_block_solutions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<CoinbaseSolution<N>>, Error>
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.
Sourcefn get_solution(
&self,
puzzle_commitment: &PuzzleCommitment<N>,
) -> Result<ProverSolution<N>, Error>
fn get_solution( &self, puzzle_commitment: &PuzzleCommitment<N>, ) -> Result<ProverSolution<N>, Error>
Returns the prover solution for the given solution ID.
Sourcefn get_block_transactions(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Transactions<N>>, Error>
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.
Sourcefn get_block_aborted_transaction_ids(
&self,
block_hash: &<N as Network>::BlockHash,
) -> Result<Option<Vec<<N as Network>::TransactionID>>, Error>
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.
Sourcefn get_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error>
fn get_transaction( &self, transaction_id: &<N as Network>::TransactionID, ) -> Result<Option<Transaction<N>>, Error>
Returns the transaction for the given transaction ID.
Sourcefn get_confirmed_transaction(
&self,
transaction_id: <N as Network>::TransactionID,
) -> Result<Option<ConfirmedTransaction<N>>, Error>
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.
Sourcefn get_unconfirmed_transaction(
&self,
transaction_id: &<N as Network>::TransactionID,
) -> Result<Option<Transaction<N>>, Error>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.