Trait snarkvm_compiler::BlockStorage
source · [−]pub trait BlockStorage<N: Network>: Clone + Sync {
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 TransactionsMap: for<'a> Map<'a, N::BlockHash, Vec<N::TransactionID>>;
type ReverseTransactionsMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>;
type TransactionStorage: TransactionStorage<N, TransitionStorage = Self::TransitionStorage>;
type TransitionStorage: TransitionStorage<N>;
type SignatureMap: for<'a> Map<'a, N::BlockHash, Signature<N>>;
Show 22 methods
fn open() -> Result<Self>;
fn id_map(&self) -> &Self::IDMap;
fn reverse_id_map(&self) -> &Self::ReverseIDMap;
fn header_map(&self) -> &Self::HeaderMap;
fn transactions_map(&self) -> &Self::TransactionsMap;
fn reverse_transactions_map(&self) -> &Self::ReverseTransactionsMap;
fn transaction_store(
&self
) -> &TransactionStore<N, Self::TransactionStorage>;
fn signature_map(&self) -> &Self::SignatureMap;
fn start_atomic(&self) { ... }
fn is_atomic_in_progress(&self) -> bool { ... }
fn abort_atomic(&self) { ... }
fn finish_atomic(&self) -> Result<()> { ... }
fn insert(&self, block: &Block<N>) -> Result<()> { ... }
fn remove(&self, block_hash: &N::BlockHash) -> Result<()> { ... }
fn find_block_hash(
&self,
transaction_id: &N::TransactionID
) -> Result<Option<N::BlockHash>> { ... }
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_transactions(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Transactions<N>>> { ... }
fn get_block_signature(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Signature<N>>> { ... }
fn get_block(&self, block_hash: &N::BlockHash) -> Result<Option<Block<N>>> { ... }
}
Expand description
A trait for block storage.
Required Associated Types
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
.
The mapping of block hash
to block header
.
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 ReverseTransactionsMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>
type ReverseTransactionsMap: for<'a> Map<'a, N::TransactionID, N::BlockHash>
The mapping of transaction ID
to block hash
.
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.
sourcetype SignatureMap: for<'a> Map<'a, N::BlockHash, Signature<N>>
type SignatureMap: for<'a> Map<'a, N::BlockHash, Signature<N>>
The mapping of block hash
to block signature
.
Required Methods
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.
sourcefn transactions_map(&self) -> &Self::TransactionsMap
fn transactions_map(&self) -> &Self::TransactionsMap
Returns the transactions map.
sourcefn reverse_transactions_map(&self) -> &Self::ReverseTransactionsMap
fn reverse_transactions_map(&self) -> &Self::ReverseTransactionsMap
Returns the reverse transactions map.
sourcefn transaction_store(&self) -> &TransactionStore<N, Self::TransactionStorage>
fn transaction_store(&self) -> &TransactionStore<N, Self::TransactionStorage>
Returns the transaction store.
sourcefn signature_map(&self) -> &Self::SignatureMap
fn signature_map(&self) -> &Self::SignatureMap
Returns the signature map.
Provided Methods
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 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.
Removes the block for the given block hash
.
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 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
.
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_signature(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Signature<N>>>
fn get_block_signature(
&self,
block_hash: &N::BlockHash
) -> Result<Option<Signature<N>>>
Returns the block signature for the given block hash
.