Trait snarkvm_ledger_store::BlockStorage
source · pub trait BlockStorage<N: Network>: 'static + Clone + Send + Sync {
Show 68 associated items
type StateRootMap: for<'a> Map<'a, u32, N::StateRoot>;
type ReverseStateRootMap: for<'a> Map<'a, N::StateRoot, u32>;
type IDMap: for<'a> Map<'a, u32, N::BlockHash>;
type ReverseIDMap: for<'a> Map<'a, N::BlockHash, u32>;
type HeaderMap: for<'a> Map<'a, N::BlockHash, Header<N>>;
type AuthorityMap: for<'a> Map<'a, N::BlockHash, Authority<N>>;
type CertificateMap: for<'a> Map<'a, Field<N>, (u32, u64)>;
type RatificationsMap: for<'a> Map<'a, N::BlockHash, Ratifications<N>>;
type SolutionsMap: for<'a> Map<'a, N::BlockHash, Option<CoinbaseSolution<N>>>;
type PuzzleCommitmentsMap: for<'a> Map<'a, PuzzleCommitment<N>, u32>;
type TransactionsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>;
type AbortedTransactionIDsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>;
type RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>;
type ConfirmedTransactionsMap: for<'a> Map<'a, N::TransactionID, (N::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>;
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<()> { ... }
fn insert(&self, state_root: N::StateRoot, block: &Block<N>) -> Result<()> { ... }
fn remove(&self, block_hash: &N::BlockHash) -> Result<()> { ... }
fn contains_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool> { ... }
fn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool> { ... }
fn contains_rejected_deployment_or_execution_id(
&self,
rejected_id: &Field<N>
) -> Result<bool> { ... }
fn find_block_height_from_state_root(
&self,
state_root: N::StateRoot
) -> Result<Option<u32>> { ... }
fn find_block_hash(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<N::BlockHash>> { ... }
fn find_block_height_from_puzzle_commitment(
&self,
puzzle_commitment: &PuzzleCommitment<N>
) -> Result<Option<u32>> { ... }
fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>> { ... }
fn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
block_tree: &BlockTree<N>
) -> Result<StatePath<N>> { ... }
fn get_previous_block_hash(
&self,
height: u32
) -> Result<Option<N::BlockHash>> { ... }
fn get_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>> { ... }
fn get_block_height(&self, block_hash: &N::BlockHash) -> Result<Option<u32>> { ... }
fn get_block_header(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Header<N>>> { ... }
fn get_block_authority(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Authority<N>>> { ... }
fn get_batch_certificate(
&self,
certificate_id: &Field<N>
) -> Result<Option<BatchCertificate<N>>> { ... }
fn get_block_ratifications(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Ratifications<N>>> { ... }
fn get_block_solutions(
&self,
block_hash: &N::BlockHash
) -> Result<Option<CoinbaseSolution<N>>> { ... }
fn get_solution(
&self,
puzzle_commitment: &PuzzleCommitment<N>
) -> Result<ProverSolution<N>> { ... }
fn get_block_transactions(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Transactions<N>>> { ... }
fn get_block_aborted_transaction_ids(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Vec<N::TransactionID>>> { ... }
fn get_transaction(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<Transaction<N>>> { ... }
fn get_confirmed_transaction(
&self,
transaction_id: N::TransactionID
) -> Result<Option<ConfirmedTransaction<N>>> { ... }
fn get_unconfirmed_transaction(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<Transaction<N>>> { ... }
fn get_block(&self, block_hash: &N::BlockHash) -> Result<Option<Block<N>>> { ... }
}
Expand description
A trait for block storage.
Required Associated Types§
sourcetype StateRootMap: for<'a> Map<'a, u32, N::StateRoot>
type StateRootMap: for<'a> Map<'a, u32, N::StateRoot>
The mapping of block height
to state root
.
sourcetype ReverseStateRootMap: for<'a> Map<'a, N::StateRoot, u32>
type ReverseStateRootMap: for<'a> Map<'a, N::StateRoot, u32>
The mapping of state root
to block height
.
sourcetype ReverseIDMap: for<'a> Map<'a, N::BlockHash, u32>
type ReverseIDMap: for<'a> Map<'a, N::BlockHash, u32>
The mapping of block hash
to block height
.
sourcetype HeaderMap: for<'a> Map<'a, N::BlockHash, Header<N>>
type HeaderMap: for<'a> Map<'a, N::BlockHash, Header<N>>
The mapping of block hash
to block header
.
sourcetype AuthorityMap: for<'a> Map<'a, N::BlockHash, Authority<N>>
type AuthorityMap: for<'a> Map<'a, N::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::BlockHash, Ratifications<N>>
type RatificationsMap: for<'a> Map<'a, N::BlockHash, Ratifications<N>>
The mapping of block hash
to block ratifications
.
sourcetype SolutionsMap: for<'a> Map<'a, N::BlockHash, Option<CoinbaseSolution<N>>>
type SolutionsMap: for<'a> Map<'a, N::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::BlockHash, Vec<N::TransactionID>>
type TransactionsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>
The mapping of block hash
to [transaction ID]
.
sourcetype AbortedTransactionIDsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>
type AbortedTransactionIDsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>
The mapping of block hash
to [aborted transaction ID]
.
sourcetype RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>
type RejectedOrAbortedTransactionIDMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>
The mapping of rejected or aborted transaction ID
to block hash
.
sourcetype ConfirmedTransactionsMap: for<'a> Map<'a, N::TransactionID, (N::BlockHash, ConfirmedTxType, Vec<u8>)>
type ConfirmedTransactionsMap: for<'a> Map<'a, N::TransactionID, (N::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<()>
fn finish_atomic(&self) -> Result<()>
Finishes an atomic batch write operation.
sourcefn insert(&self, state_root: N::StateRoot, block: &Block<N>) -> Result<()>
fn insert(&self, state_root: N::StateRoot, block: &Block<N>) -> Result<()>
Stores the given (state root, block)
pair into storage.
sourcefn remove(&self, block_hash: &N::BlockHash) -> Result<()>
fn remove(&self, block_hash: &N::BlockHash) -> Result<()>
Removes the block for the given block hash
.
sourcefn contains_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool>
fn contains_transaction_id( &self, transaction_id: &N::TransactionID ) -> Result<bool>
Returns true
if the given transaction ID exists.
sourcefn contains_rejected_or_aborted_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool>
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.
sourcefn contains_rejected_deployment_or_execution_id(
&self,
rejected_id: &Field<N>
) -> Result<bool>
fn contains_rejected_deployment_or_execution_id( &self, rejected_id: &Field<N> ) -> Result<bool>
Returns true
if the given rejected deployment or execution ID.
sourcefn find_block_height_from_state_root(
&self,
state_root: N::StateRoot
) -> Result<Option<u32>>
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
.
sourcefn find_block_hash(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<N::BlockHash>>
fn find_block_hash( &self, transaction_id: &N::TransactionID ) -> Result<Option<N::BlockHash>>
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>>
fn find_block_height_from_puzzle_commitment( &self, puzzle_commitment: &PuzzleCommitment<N> ) -> Result<Option<u32>>
Returns the block height that contains the given puzzle commitment
.
sourcefn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
Returns the state root that contains the given block height
.
sourcefn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
block_tree: &BlockTree<N>
) -> Result<StatePath<N>>
fn get_state_path_for_commitment( &self, commitment: &Field<N>, block_tree: &BlockTree<N> ) -> Result<StatePath<N>>
Returns a state path for the given commitment
.
sourcefn get_previous_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
fn get_previous_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
Returns the previous block hash of the given block height
.
sourcefn get_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
fn get_block_hash(&self, height: u32) -> Result<Option<N::BlockHash>>
Returns the block hash for the given block height
.
sourcefn get_block_height(&self, block_hash: &N::BlockHash) -> Result<Option<u32>>
fn get_block_height(&self, block_hash: &N::BlockHash) -> Result<Option<u32>>
Returns the block height for the given block hash
.
sourcefn get_block_header(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Header<N>>>
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
.
sourcefn get_batch_certificate(
&self,
certificate_id: &Field<N>
) -> Result<Option<BatchCertificate<N>>>
fn get_batch_certificate( &self, certificate_id: &Field<N> ) -> Result<Option<BatchCertificate<N>>>
Returns the batch certificate for the given certificate ID
.
sourcefn get_block_ratifications(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Ratifications<N>>>
fn get_block_ratifications( &self, block_hash: &N::BlockHash ) -> Result<Option<Ratifications<N>>>
Returns the block ratifications for the given block hash
.
sourcefn get_block_solutions(
&self,
block_hash: &N::BlockHash
) -> Result<Option<CoinbaseSolution<N>>>
fn get_block_solutions( &self, block_hash: &N::BlockHash ) -> Result<Option<CoinbaseSolution<N>>>
Returns the block solutions for the given block hash
.
sourcefn get_solution(
&self,
puzzle_commitment: &PuzzleCommitment<N>
) -> Result<ProverSolution<N>>
fn get_solution( &self, puzzle_commitment: &PuzzleCommitment<N> ) -> Result<ProverSolution<N>>
Returns the prover solution for the given solution ID.
sourcefn get_block_transactions(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Transactions<N>>>
fn get_block_transactions( &self, block_hash: &N::BlockHash ) -> Result<Option<Transactions<N>>>
Returns the block transactions for the given block hash
.
sourcefn get_block_aborted_transaction_ids(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Vec<N::TransactionID>>>
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
.
sourcefn get_transaction(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<Transaction<N>>>
fn get_transaction( &self, transaction_id: &N::TransactionID ) -> Result<Option<Transaction<N>>>
Returns the transaction for the given transaction ID
.
sourcefn get_confirmed_transaction(
&self,
transaction_id: N::TransactionID
) -> Result<Option<ConfirmedTransaction<N>>>
fn get_confirmed_transaction( &self, transaction_id: N::TransactionID ) -> Result<Option<ConfirmedTransaction<N>>>
Returns the confirmed transaction for the given transaction ID
.
sourcefn get_unconfirmed_transaction(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<Transaction<N>>>
fn get_unconfirmed_transaction( &self, transaction_id: &N::TransactionID ) -> Result<Option<Transaction<N>>>
Returns the unconfirmed transaction for the given transaction ID
.